[JupyterHub on Kubernetes] LSP server extension not found + Failed to load the jupyterlab-git server extension

Hey guys, I’ve been following this documentation and managed set up JupyterHub running on Kubernetes.

However, when it comes to installing jupyterlab-git extension. I’ve bumped into this issue.

Failed to load the jupyterlab-git server extension
Git server extension is unavailable. Please ensure you have installed the JupyterLab Git server extension by running: pip install --upgrade jupyterlab-git. To confirm that the server extension is installed, run: jupyter server extension list.

Has anyone experienced this before and managed to solve it? Thanks!

The title mentions LSP, but the body refers to jupyterlab-git.

In both cases, these respective packages (jupyterlab-git and jupyterlab-lsp) need to be installed in the environment before the jupyter_server starts, which usually means baking them into your images: to my knowledge there is not yet a docker-stacks image that includes either of them, so you’ll need to extend them with a custom dockerfile with FROM your chosen base image.

Specifically for jupyterlab-lsp, you’d also need appropriate language servers installed and on $PATH prior to starting the jupyter_server in the container.

2 Likes

Hey @bollwyvl, thanks so much for helping.

I did not bake it into the image but did the following in my installation (with Helm).

When I run

- display_name: "Datascience environment"
  description: "With popular packages from scientific Python environment."
  kubespawner_override:
    image: jupyter/scipy-notebook:python-3.9.12
    lifecycle_hooks:
      postStart:
        exec:
          command:
            [
              "/bin/bash",
              "-c",
              "pip install --upgrade jupyterlab-git jupyterlab-lsp",
            ]

When I tried running jupyter server extension list, I can see the following. However, the git extension is still not installed.

Config dir: /home/jovyan/.jupyter

Config dir: /opt/conda/etc/jupyter
    jupyter_lsp enabled
    - Validating jupyter_lsp...
      jupyter_lsp 1.5.1 OK
    jupyter_server_mathjax enabled
    - Validating jupyter_server_mathjax...
      jupyter_server_mathjax  OK
    jupyterlab enabled
    - Validating jupyterlab...
      jupyterlab 3.4.2 OK
    jupyterlab_git enabled
    - Validating jupyterlab_git...
      jupyterlab_git 0.39.2 OK
    nbclassic enabled
    - Validating nbclassic...
      nbclassic  OK
    nbdime enabled
    - Validating nbdime...
      nbdime 3.1.1 OK
    notebook_shim enabled
    - Validating notebook_shim...
      notebook_shim  OK

Config dir: /usr/local/etc/jupyter

Thanks @bollwyvl for the advice. It turns out that the packages have to be installed first before the server starts up. With my previous solution, the packages are installed AFTER jupyter has started. I hence need to build my own image with those packages baked in and use it for my environment.

FROM jupyter/scipy-notebook:python-3.9.12

# install additional package...
RUN pip install --upgrade jupyterlab-git jupyterlab-lsp

Glad that worked out.

If you are already working with docker-stacks, whatever your opinion of conda/mamba, most of the packages are already installed with mamba in ${CONDA_DIR}. For the most part, this is already handled, though semi-badly, as it relies on path hacks rather than full env activation.

At any rate, I recommend emulating the approach from docker-stacks, as you are more likely to end up with a consistent, complete, and reproducible environment, including language servers,

So, a semi-extensive installation that jupyter-lsp might autodetect might be:

RUN mamba install --quiet --yes \
    'jupyterlab-git' \
    'jupyterlab-lsp' \
    'jupyter-lsp-python-plugins' \ # see https://github.com/conda-forge/jupyter-lsp-feedstock/blob/c3f3d8ab11b2668a8d8e9eb9b1a7cd3cef737e3a/recipe/meta.yaml#L111
    'json-lsp' \                   # there are others
    'yaml-lsp' \                   # want
    mamba clean --all -f -y && \
    fix-permissions "${CONDA_DIR}" && \
    fix-permissions "/home/${NB_USER}"