jupyterhub / the-littlest-jupyterhub

Simple JupyterHub distribution for 1-100 users on a single server
https://tljh.jupyter.org
BSD 3-Clause "New" or "Revised" License
1.04k stars 340 forks source link

Struggling to install jupyterlab-git extension #467

Closed harrybiddle closed 3 years ago

harrybiddle commented 4 years ago

Hey,

I am struggling to install the jupyterlab-git extension. It works fine for me with the same versions of JupyterHub + Lab locally, so I think it is a TLJH difficulty I am having.

I have installed the server extension in both the hub and the user environments:

sudo su
. /opt/tljh/hub/bin/activate
pip install jupyterlab-git
jupyter serverextension enable --py jupyterlab_git
sudo su
. /opt/tljh/user/bin/activate
pip install jupyterlab-git
jupyter serverextension enable --py jupyterlab_git

Furthemore I have installed the lab extension for the GUI in the user environment:

sudo su
. /opt/tljh/user/bin/activate
jupyter labextension install @jupyterlab/git

The right elements show up in the lab GUI, but I get a 404 when hitting one of the endpoints the extension needs, namely git/all_history.

There is nothing in either the jupyterhub nor the jupyterhub- journalctl. I tried to up the logging level but there was nothing in the RTFM docs and I couldn't figure it out. I also tried to figure out if this is an issue with one of the proxies dropping the route or whether the extension isn't being loaded.

I'm struggling to figure out where exactly the problem lies... Can anybody help?

harrybiddle commented 4 years ago

Ok, I figured this out. It needed

sudo chown ubuntu /usr/local/etc/
. /opt/tljh/user/bin/activate
jupyter serverextension enable --py jupyterlab_git --system

I think what really would have helped me in this is a more thorough description of how the different virtualenv environments work, as well as some examples in the documentation of installing extensions. Would you welcome a PR for this?

GeorgianaElena commented 4 years ago

Hi @harrybiddle! Sorry for the late reply. Happy you manage to get it work and thanks for posting the solution here :sun_with_face:

Would you welcome a PR for this?

A PR is definitely welcomed and would be highly appreciated.

lwbayes commented 4 years ago

@harrybiddle Have you been able to make this plugin work? For me, it always shows as "You aren’t in a git repository." The path of the plugin should change as we change the path of the folder, but it does not.

harrybiddle commented 4 years ago

I did manage to get it to to work, in the end. I remember seeing the same message as you did for a very long time; I did a whole bunch of things and now I forgot what I did!

Some random shots in the dark:

The path of the plugin should change as we change the path of the folder, but it does not.

How did you conclude this was the cause?

lwbayes commented 4 years ago

@harrybiddle Thank you for the reply!

harrybiddle commented 4 years ago

Only reason I surmised this is that if I make the user home a git repo, the plugin is working. I guess I'll dig into the logs to see what's up

Oh, I see. That is odd. I've checked on my deploy and confirmed that the user's home is not a Git repo, and when I click Git > Git Interface it correctly reports "You aren't in a git repository". If I navigate into a directory that is a Git repository then Git > Git Interface works. This is jupyterlab-git===0.8.1.

aolney commented 4 years ago

It seems you can install with conda, e.g.

sudo -E conda install jupyterlab-git -c conda-forge

and this resolves issues with the virtual environment.

kparaju commented 4 years ago

I'm not sure if this should be a catch-all jupyterhub and jupyterlab-git issues list.. but wanted to comment in case this helps anyone.

In jupterlab-git 0.20.0 I was seeing the following error. I locked the version to 0.10.1 and it's working now.

Enabling: jupyterlab_git
- Writing config: /usr/local/etc/jupyter
    - Validating...
      jupyterlab_git 0.20.0 OK
Building jupyterlab assets (build:prod:minimize)
An error occured.
RuntimeError: JupyterLab failed to build
See the log file for details:  /tmp/jupyterlab-debug-j_uk6rzc.log
The command '/bin/bash -o pipefail -c conda install jupyterlab-git -c conda-forge &&   jupyter serverextension enable --py jupyterlab_git --system &&   jupyter labextension install @jupyterlab/git' returned a non-zero code: 1

(.... snip ....) (from /tmp/jupyterlab-debug-j_uk6rzc.log)

Child
    Hash: 7845e9ccd74e15e362eb
    Time: 2969ms
    Built at: 06/24/2020 2:36:41 PM
        Asset       Size  Chunks             Chunk Names
    index.css   14.7 KiB       0  [emitted]  index
     index.js  932 bytes       0  [emitted]  index
    Entrypoint index = index.css index.js
       3 modules
    Child mini-css-extract-plugin node_modules/css-loader/dist/cjs.js!node_modules/@jupyterlab/theme-light-extension/style/index.css:
        Entrypoint mini-css-extract-plugin = *
           3 modules
child_process.js:632
    throw err;
    ^

Error: Command failed: /opt/conda/share/jupyter/lab/staging/node_modules/.bin/webpack --config webpack.prod.minimize.config.js
    at checkExecSyncError (child_process.js:611:11)
    at Object.execFileSync (child_process.js:629:15)
    at Object.<anonymous> (/opt/conda/share/jupyter/lab/staging/node_modules/@jupyterlab/buildutils/lib/ensure-max-old-space.js:38:17)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:972:32)
    at Function.Module._load (internal/modules/cjs/loader.js:872:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  status: 2,
  signal: null,
  output: [ null, null, null ],
  pid: 7773,
  stdout: null,
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

JupyterLab failed to build
Traceback (most recent call last):

  File "/opt/conda/lib/python3.7/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging
    yield

  File "/opt/conda/lib/python3.7/site-packages/jupyterlab/labextensions.py", line 105, in start
    command=command, app_options=app_options)

  File "/opt/conda/lib/python3.7/site-packages/jupyterlab/commands.py", line 460, in build
    command=command, clean_staging=clean_staging)

  File "/opt/conda/lib/python3.7/site-packages/jupyterlab/commands.py", line 661, in build
    raise RuntimeError(msg)

RuntimeError: JupyterLab failed to build
parmentelat commented 4 years ago

hello there

I'm experiencing the same kind of symptoms, on a docker image built on top of the latest scipy-notebook image from docker-stacks (i.e. my Dockerfile has FROM jupyter/scipy-notebook:latest)

the symptom is this screenshot

jupyterlab-git-error

I believe I have everything in place, as the image runs

pip install -U jupyterlab jupyterlab-git
jupyter labextension install @jupyterlab/git
jupyter serverextension enable --py jupyterlab_git

also a runtime check exhibits this

root@f1a6f7a87d15:~# jupyter labextension list
JupyterLab v2.2.4
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @jupyterlab/git v0.21.0-alpha.0  enabled  OK
        jupyterlab-jupytext v1.2.1  enabled  OK
        nbdime-jupyterlab v2.0.0  enabled  OK

root@f1a6f7a87d15:~# pip show jupyterlab-git
WARNING: The directory '/home/jovyan/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Name: jupyterlab-git
Version: 0.20.0
<snip>

the funny thing is that the whole business was working just fine about one or two weeks ago; it feels like something has changed recently in that base image, that I pulled again recently, or in the ecosystem, although I cannot be 100% positive it's not on my end; and unfortunately I do not know the version number for jupyterlab_git at that time

just being curious but, has anybody met something similar recently ?

aolney commented 4 years ago

In my very limited experience with TLJH, you want to do installs like this from a TLJH terminal, not a regular terminal, and use sudo -E as described here. This has always worked for me, but I haven't done a new install in the last couple of months.

While it is allegedly possible to do these things from a normal terminal, weirdness seems to sometimes occur when you do something nontrivial. From your shell output, this seems to be the approach you followed.

My recommendation would be to uninstall and do from TLJH's terminal using sudo -E conda install jupyterlab-git -c conda-forge

JavierHernandezMontes commented 3 years ago

@aolney hello did you manage to solve the issue? I am experimenting the same issue right now

parmentelat commented 3 years ago

I no longer experience this issue on recent builds of the docker-stack images

aolney commented 3 years ago

@JavierHernandezMontes using the conda install approach works for me. Use the TLJH terminal and execute sudo -E conda install jupyterlab-git -c conda-forge

JavierHernandezMontes commented 3 years ago

Ok, I finally managed to installed the problem it was that I had a previous configuration deleting /settings/build_config.json where in jupyter lab paths did the trick.

I guess this issue could be closed

consideRatio commented 3 years ago

Resolved by https://github.com/jupyterhub/the-littlest-jupyterhub/issues/467#issuecomment-556135481.

I'm opening #735 as I think it's very relevant to have a crystal clear description on the various environments where TLJH is active in some way.