Pre-built extensions and labextension disable not working?

Am I doing something wrong here? I have lab extensions that I distribute as pre-built extensions. Multiple UI extensions are all bundled in one Python package. Once they are all installed, if I want to disable only one, I should be able to do jupyter labextension disable foo but that doesn’t seem to be working with pre-built because they are included just by mere existence and still auto-run.

As an example: If I install jupyterlab-nbgallery, then disable @jupyterlab-nbgallery/gallerymenu and reload lab, that plugin is still executed.

Code: lab-extensions/gallerymenu at main · nbgallery/lab-extensions · GitHub
Environment:

$>jupyter labextension disable @jupyterlab-nbgallery/gallerymenu
$>jupyter labextension list
JupyterLab v3.4.3
/opt/conda/share/jupyter/labextensions
...
        @jupyterlab-nbgallery/environment-registration v1.0.0 enabled OK
        @jupyterlab-nbgallery/gallerymenu v1.0.0 disabled OK
        @jupyterlab-nbgallery/inject-uuid v1.0.0 enabled OK
...

Disabled extensions:
    @jupyterlab-nbgallery/gallerymenu (all plugins)

I have recently been learning about managing extensions as well. I have a custom lab extension and wanted to enable/disable individual plugins like how I can with the JupyterLab help extension, which has four different plugins that can be individually controlled.

One thing I know is that you need to use the plugin ID, for example @jupyterlab/help-extension:jupyter-forum for the Jupyter Forum plugin.

I’m not familiar with this repo, but it looks like if you want to disable the gallerymenu plugin from nbgallery, the plugin ID is @jupyterlab-gallery/gallerymenu, slightly different from the plugin name you used in your example.

1 Like

Using this approach, I was able to enable/disable individual plugins in my own custom JupyterLab extension with one problem. For example, if I disable a single plugin and then run jupyter labextension list, it doesn’t list the individual plugin as being disabled, but when I run jupyter lab, I can see based on the behavior that it is disabled. The JupyterLab help extension I mentioned previously doesn’t have this problem – the disabled plugins get listed properly. :confused:

What is in your jupyter labextension list (is it listed as enabled or not at all)? How does it look when it is enabled? What version of JupyterLab?

Oh, wow, thanks for asking!

I’m using jupyterlab version 3.4.5 with retrolab version 0.3.21, and my custom extension jupyterlab-cdanner, all installed using pip. (I built my extension using python -m build and pip installed from the wheel file.)

jupyter labextension list gives me the following.

JupyterLab v3.4.5
/opt/home/build/.pyenv/versions/3.9.12/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        jupyterlab-cdanner v0.1.0 enabled OK (python, jupyterlab_cdanner)
        @retrolab/lab-extension v0.3.21 enabled OK

Disabled extensions:
    @retrolab/lab-extension:interface-switcher

I have a plugin with plugin ID @cdanner/lab-extension:hide-menu-plugin that hides the RetroLab main menu in my notebook, and I found that I can disable it using jupyter labextension disable @cdanner/lab-extension:hide-menu-plugin. However, if I run jupyter labextension disable, the output is identical to the previous, although the behavior reflects it being disabled.

2 Likes

Oh, I did not mention this, but yes, I also disabled the RetroLab interface switcher plugin because I wanted it disabled, and it shows up on the disabled list as I would expect.

1 Like

Looks like a bug. I was not able to reproduce with my extensions but maybe we do something different. I tried:

jupyter labextension disable @krassowski/jupyterlab-lsp:hover

and then the list correctly shows it as disabled:

JupyterLab v3.4.5
~/.local/share/jupyter/labextensions
        nbdime-jupyterlab v2.1.0 enabled OK

../envs/x/share/jupyter/labextensions
        jupyter-cytoscape v1.3.3 enabled OK
        jupyter-matplotlib v0.11.0 enabled OK
        spreadsheet-editor v0.6.1 enabled OK (python, jupyterlab-spreadsheet-editor)
        jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
        jupyterlab-dagitty v0.3.5 enabled OK (python, jupyterlab-dagitty)
        jupyterlab-unfold v0.2.2 enabled OK (python, jupyterlab-unfold)
        @jupyter-server/resource-usage v0.6.1 enabled OK (python, jupyter-resource-usage)
        @ijmbarr/jupyterlab_spellchecker v0.7.2 enabled OK (python, jupyterlab-spellchecker)
        @jupyterlab/git v0.37.1 enabled OK (python, jupyterlab-git)
        @krassowski/jupyterlab-lsp v3.10.1 enabled OK (python, jupyterlab-lsp)
        @jupyter-widgets/jupyterlab-sidecar v0.6.1 disabled OK (python, sidecar)
        @jupyter-widgets/jupyterlab-manager v3.1.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: ../envs/x/share/jupyter/lab


Disabled extensions:
    @jupyter-widgets/jupyterlab-sidecar (all plugins)
    @krassowski/jupyterlab-lsp:hover

The following source extensions are overshadowed by older prebuilt extensions:
    nbdime-jupyterlab

Would you mind opening an issue on Issues · jupyterlab/jupyterlab · GitHub with a reproducible example (minimal code of the @cdanner/lab-extension:hide-menu-plugin plugin that is necessary to reproduce and step-by-step instructions).

2 Likes

Sure, and thanks for your response!

I stared at this and stared at this, and FINALLY saw the problem in mine (one says gallery, one says nbgallery) so…yeah, time to patch the extensions so the plugin ids are correct.
for those looking for more detail, my package.json has one name and the plugin id in the package was a slightly different name in most of my packages. the package.json value is what is displayed in the jupyter labextension list, not hte plugin id, but if you disable with a string that matches the plugin id it won’t show up in the labextension list but will be disabled.

2 Likes

@mcrutch, thanks for pointing this out. I never would’ve checked the package.json file. I think the way an error like this creeps in is that – or at least what happened for me – is that I typed in one name for the project when filling out the fields from cookie-cutter, then later on decided to change the name of the plugins and changed it in the .ts file but don’t realize it needed to be changed in the package.json file too.

I modified my plugin names to start with @ because I saw that RetroLab and JupyterLab were doing that. I just checked the RetroLab package.json, and the name in there starts with @, so um, I guess that’s important, haha.

But it turns out that wasn’t the only problem with my plugin naming. Another thing I copied from RetroLab and JupyterLab was that their plugins are named like @retrolab/lab-extension:launch-retrotree. I copied that pattern in naming my plugins, and apparently having the /lab-extension was also a problem for me. I got rid of the @ and the /lab-extension in my plugin names, and now jupyter labextension list is working for me.

It’s super weird that the actual enable disable of the plugin behaviors was working this whole time even when jupyter labextension list didn’t reflect that though.