The server extension appears to be missing, when launching with mybinder.org

When I create a JupyterLab extension that has a server component and launch it in mybinder.org, I see the error, “The jupyterlab_ext server extension appears to be missing.” in the console. jupyterlab_ext is the name of this test extension.

This is a summary of the actions that I take in creating the extension and pushing it to Github.

conda create -n jupyterlab-ext --override-channels --strict-channel-priority -c conda-forge -c anaconda jupyterlab=3 cookiecutter nodejs jupyter-packaging git
conda activate jupyterlab-ext
cookiecutter https://github.com/jupyterlab/extension-cookiecutter-ts
cd jupyterlab_ext
git init
git add .
git commit -m 'first commit'
git branch -M main
git remote add origin git@github.com:educational-technology-collective/jupyterlab-ext.git
git push -u origin main
pip install -ve .
jupyter labextension develop --overwrite .
jupyter server extension enable jupyterlab_ext
jlpm run build
git add .
git commit -m 'commit'
git push origin main

For reference, this is the resulting test repo: GitHub - educational-technology-collective/jupyterlab-ext

At this point I click the binder button in the README.md file. JupyterLab launches, however the cookiecutter request to the server fails.

When I open a terminal in Binder and run jupyter server extension list I do not see the server extension listed.

Hence, I add the line _(sys.executable, "-m", "jupyter", "server", "extension", "enable", "jupyterlab_ext") to ./binder/postBuild. And, I commit and push the repo to GitHub.

At this point I click the binder button in the README.md file. JupyterLab launches, however the cookiecutter request to the server fails.

When I open a terminal in Binder and run jupyter server extension list I see the server extension listed:

jupyterlab_ext enabled
    - Validating jupyterlab_ext...
      jupyterlab_ext 0.1.0 OK

However, as I indicated, the request to the server extension that is made in the activate function fails.

It appears that after adding the code to postBuild, the server extension is found, however, perhaps, there is something wrong with the path of the request - I’m not sure.

The same test extension runs as expected on my local machine i.e., the request to the server component works.

Can anyone assist with this? You can observe the phenomenon by launching the Binder from the repo that I posted. If I should create an Issue, can you tell me which repo I should make the Issue in?

I thought I should add that when I create a Binder using a Dockerfile and launch it on mybinder.org, the server extension works fine. In that scenario I am installing prebuilt extensions from wheels.

This might be due to the difference between launching JupyterLab via jupyter-notebook (as done on mybinder and JupyterHub by default) vs jupyter-server. I’m pretty sure there’s other posts about it on this forum but I can’t find them…

If this is the problem then if you run jupyter-notebook locally and go to /lab you should have the same issue. You can try making your extension compatible with both methods of launching JupyterLab:
https://jupyter-server.readthedocs.io/en/latest/developers/extensions.html#migrating-an-extension-to-use-jupyter-server

1 Like

@manics Thank you. I checked the thread, Backward compatibility for server extension on jupyterhub by SarunasAzna · Pull Request #863 · jupyterlab/jupyterlab-git · GitHub, and it appears that all the changes that need to be implemented for compatibility have been implemented.

Could it be that installing an extension in development mode doesn’t work for jupyter-notebook?

Something that I think supports that hypothesis is that everything works perfectly when the extension is installed as a prebuilt extension.

_(sys.executable, "-m", "pip", "install", "-e", ".")

_(sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", ".")

_(sys.executable, "-m", "jupyter", "server", "extension", "enable", "jupyterlab_ext")

That sounds plausible- hopefully one of the JupyterLab developers can explain!

I was able to get the server extension to run on mybinder.org by just changing _(sys.executable, “-m”, “pip”, “install”, “-e”, “.”) to _(sys.executable, “-m”, “pip”, “install”, “.”) in postBuild.

1 Like

@jtp Would you like for me to create an Issue in the cookiecutter repo regarding this issue?