Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable labextension for user only #15574

Open
brichet opened this issue Dec 28, 2023 · 3 comments
Open

Enable labextension for user only #15574

brichet opened this issue Dec 28, 2023 · 3 comments

Comments

@brichet
Copy link
Contributor

brichet commented Dec 28, 2023

EDIT

The description below may not be relevant anymore, but the issue is still there, since the extension cannot be enabled at user level only.
See #15574 (comment) for updated context on the issue.

Description

Labextensions can be enabled/disabled at several level: user, sys_prefix or system level.

The way it works in jupyterlab is to write a file if the extension is explicitly disabled.

To know if an extension is enabled or disabled when starting jupyterlab, I believe the page_config files are read in this order: user, sys_prefix and system. If a file is missing at one of this level, the extension is considered unset at this level, which means enabled by default except if a page_config file is found at another level.

Now, if we want to enable an extension only for some users, we should run the following commands:

  • jupyter labextension disable my_extension --level=sys_prefix
  • jupyter labextension enable my_extension --level=user

These commands will create an entry to disable the extension at sys_prefix level, but not at user level. Therefore the extension will be considered as disabled because there is no file at user level but one at sys_prefix level.

To make it work properly, we need to first disable the extension at user level (to create the entry), then enable it to modify the entry.

  • jupyter labextension disable my_extension --level=sys_prefix
  • jupyter labextension disable my_extension --level=user
  • jupyter labextension enable my_extension --level=user

Reproduce

The following commands will not enable the extension for the user:

  • jupyter labextension disable my_extension --level=sys_prefix
  • jupyter labextension enable my_extension --level=user

Expected behavior

To enable the extension at lower level.

Context

Issue reference jupyter/nbgrader#1515 (comment) and jupyter/nbgrader#1588 (comment)

Proposition

Change the following condition:

elif not value and is_disabled:

to:

elif not value:
@brichet
Copy link
Contributor Author

brichet commented Apr 26, 2024

Fixed by #16102

@brichet brichet closed this as completed Apr 26, 2024
@brichet brichet reopened this Apr 29, 2024
@brichet
Copy link
Contributor Author

brichet commented May 17, 2024

After #14536, #16102 and #16251, there is no issue about populating the labconfig.json file at user level.
IIUC the correct commands to enable an extension for user only is:

jupyter labextension disable my_extension --level=sys_prefix
jupyter labextension unlock my_extension --level=sys_prefix
jupyter labextension enable my_extension --level=user

These commands create/populate the labconfig.json file correctly at each level, but on my side the extension is still disabled for the user.

Is it intended to prevent user from enabling an extension, if it has been disabled but unlocked at a higher level ?

cc @krassowski @divyansshhh who worked on the PR above.

@brichet
Copy link
Contributor Author

brichet commented May 20, 2024

Some more discussion about this #16101 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants