Installing IJulia for all users for JupyterHub

Hi, I’m trying to figure out how to setup IJulia for all users on my JupyterHub server.
I know that Julia has “depots” in global locations, but I’m not sure how to install packages there. When I run Pkg.depots(), I see this:

julia> Pkg.depots()
3-element Array{String,1}:
 "/home/ubuntu/.julia"
 "/opt/julia-1.4.2/local/share/julia"
 "/opt/julia-1.4.2/share/julia"

Can someone help me out, or let me know if this is possible?

See this thread: Julia kernel on JupyterHub system-wide LDAP

2 Likes

Ok, so I’m attempting to follow the instructions on this post (Julia kernel on JupyterHub system-wide LDAP - #6 by barche) and I’m running

$ JULIA_DEPOT_PATH=/opt/julia-1.4.2/share/julia sudo julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.4) pkg> add IJulia
   Updating registry at `~/.julia/registries/General`
   Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Resolving package versions...
   Updating `~/.julia/environments/v1.4/Project.toml`
 [no changes]
   Updating `~/.julia/environments/v1.4/Manifest.toml`
 [no changes]

It looks like it’s still using the local depot. How do I get it to switch to the global one?

I’ve been trying some more stuff. With the command above, it looked like sudo was interfering with the Base.DEPOT_PATH variable getting set. What worked was this command:

$ sudo env JULIA_DEPOT_PATH=/opt/julia-1.4.2/share/julia julia

This allowed me to install IJulia to the global depot. However, after that I had to run:

$ sudo mv ~/.local/share/jupyter/kernels/julia-1.4/ /usr/share/jupyter/kernels

so the IJulia kernel could be used globally on the system. Now the kernel works systemwide on my JupyterHub server

1 Like

I’ve put together a stop-by-step guide for this:
https://github.com/mauro3/JupyterHubWithJulia

Note though that I’m not sure this is the “best” or even a “good” solution. But it seems to work from the little testing I did so far. One issue I’m not clear about is how it will interact with updating, in particular IJulia.

See also: https://github.com/jupyterhub/the-littlest-jupyterhub/issues/279

4 Likes

Thanks for your post, @camtheman256, which works for Julia 1.8.1 and Jupyterhub 2.02 hosted by an LXC container that is Ubuntu-20.04-based. A little update here.

  1. I installed Julia to /opt/ for the ease of global availability.
sudo tar -xzf julia-1.8.1-linux-x86_64.tar.gz -C /opt/
  1. vim /etc/bash.bashrc
#  The global Julia settings to work with Jupyterhub
export JULIA_HOME="/opt/julia-1.8.1"
export JULIA_PKG_SERVER="https://mirrors.bfsu.edu.cn/julia"
export JULIA_DEPOT_PATH="$JULIA_HOME/share/julia"
export PATH="$JULIA_HOME/bin:$PATH"

Note: Here’s a Julia Pkg Server list in Chinese. If you’re not sure which one to choose, just use the official one: https://pkg.julialang.org.

  1. Log out and log in to make the changes applied. Install IJulia.
(@v1.8) pkg> add IJulia
  1. Create folders and move the Julia kernel.
sudo mkdir -p /usr/share/jupyter/kernels
sudo mv ~/.local/share/jupyter/kernels/julia-1.8/ /usr/share/jupyter/kernels/

ls /usr/share/jupyter/kernels/julia-1.8/
kernel.json  logo-32x32.png  logo-64x64.png
  1. After restarting Jupyterhub or its kernel from the webpage, the Julia 1.8.1 kernel option should appear.