cadabra2 icon indicating copy to clipboard operation
cadabra2 copied to clipboard

Code highlighting does not work in Jupyter on Ubuntu 22.04 (WSL)

Open ValkerN opened this issue 8 months ago • 7 comments

Hello! Thanks for the Сadabra! I am just starting to use it and have a problem.

The code highlighting does not work for me in Jupyter and I read here (in one of the issues) it might be due to incorrect paths during installation. And it has something to do with CodeMirror and MIME type recognition. But I don't understand these aspects well enough to dig into and edit the code.

I have already tried a bunch of methods for installing Jupyter, Jupyterlab, Jupyterhub on Ubuntu 22.04 (WSL). Before Cadabra build, after Cadabra build, through PIP, Conda, Apt. Not a single option works (although the Сadabra core in Jupyter is always recognized). The Docker is the same.

In short, my question is following. Let's say I have a clean Ubuntu 22.04 (WSL). Is there some standard method (and sequence) for installation of Jupiter and Сadabra, so that all the functionality (including code highlighting) works out of the box? The initial instructions are missing this precise complete method which includes Jupiter.

ValkerN avatar Mar 23 '25 11:03 ValkerN

It doesn't work for me either. This code was written by @fjebaker and I don't really have time to investigate this soon, but maybe he can. Is there any good reason why you don't just use the Cadabra notebook? (there is a Windows installer available from the download page).

@fjebaker: I tried fixing the mimetype in cadabra2_jupyter/kernel.py to match that in lexer/cadabra.js, but highlighting still does not work.

kpeeters avatar Mar 23 '25 13:03 kpeeters

The highlighting caused me trouble when I originally wrote the implementation some time ago. I can't fully recall what it was that was making the highlighting break but I'll try and look into it to fix it!

fjebaker avatar Mar 23 '25 13:03 fjebaker

After researching this for a moment, it seems Jupyter is now using a new major version of Codemirror, which has entirely changed how the Codemirror language supports are defined. This basically means we'd need to write a whole new lexer based off of the Codemirror 6 language package template.

I still can't see how you make the language template available in Jupyter, but we'll cross that hurdle later.

I'll try to look into doing all this this when I have some time!

fjebaker avatar Mar 23 '25 14:03 fjebaker

Is there any good reason why you don't just use the Cadabra notebook? (there is a Windows installer available from the download page).

Unfortunately, the Windows version (from installer) doesn't run on my system and I can't figure out why. It keeps giving me a error for bycrypt.dll (something like "this program is not intended for Windows") and closes immediately.

Also, the Jupyter interface seems more familiar to me. And I'm thinking of modifying the JupyterHub server for my department (we do cosmology and gravity) so that the Cadabra kernel (which I found to be a great tool, thank you for it!) can be shared, like Python, Wolfram, R and some other kernels.

ValkerN avatar Mar 23 '25 14:03 ValkerN

Ok, I understand your point about setting up jupyterhub.

I would still be interested to hear why the installer fails on your system. Is there an error message or something else that can get me further with debugging this?

kpeeters avatar Mar 23 '25 15:03 kpeeters

Ok, I'll write about Windows here (maybe need to open new issue).

My installation comes with the following settings:

Image

Installation directory C:\Program Files\Cadabra. If I switch a check mark for PATH, then at the end of the installation it gives:

Image

Also, I found that the auxiliary files are installed directly into "C:\Users\USERNAME\AppData\Local", without Cadabra subfolder.

In both cases, the desktop and menu icons are not created. When trying to start cadabra2-gtk.exe, it gives the following error message (but at the same time the cadabra window opens):

cadabra-server.exe - Bad Image

"C:\Program Files\Cadabra\bycript.dll" is either not designed to run in Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0xc0e90002.

In addition, the following message is displayed in the terminal:

(cadabra2-gtk.exe:20048): Gdk-WARNING **: 19:23:05.443: ../gtk+-3.24.43/gdk/win32/gdkwindow-win32.c:527: DwmEnableBlurBehindWindow (00000000000912ba) failed: 80070018

When I close the Bad Image error message, the cadabra window shut down immediately. The behavior when running as administrator is identical.

ValkerN avatar Mar 23 '25 16:03 ValkerN

The desktop/menu icons not being created is a known issue, I've been banging my head against the wall about this one but Windows does not like me (the feeling is mutual). Please followup at https://github.com/kpeeters/cadabra2/issues/328 for that issue.

I cannot reproduce the Bad Image error with bycript.dll. If necessary please open a separate issue for this.

The DwmEnableBlurBehindWindow warning is harmless. At some point I will close that terminal window, but for now it is kinda useful for debugging purposes.

kpeeters avatar Mar 31 '25 13:03 kpeeters