Managing packages for multiple julia versions

Hi there,

I was working with Julia 1.0 in the past and now want to move my code to Julia 1.3.1. So I have downloaded the Julia 1.3.1 binaries and set a symlink to the new julia executable. When I try “using IJulia” from Julia 1.3 it complains that it is not installed, although I installed it with "Pkg.add(“IJulia”) in Julia 1.0.

Given that it does not seem to recognize the packages in ~/.julia, I would like to take the chance to set a new directory for installing packages from Julia 1.3.1, just to keep things compartmentalized. Does this make practical sense? Or would this lead to useless duplication?

I think I could easily decide on a new directory for the new Julia 1.3.1 by setting JULIA_DEPOT_PATH to my newly desired directory. However, wouldn’t this mess up the package loading from my Julia 1.0 installation?

Alternatively, could I set Base.DEPOT_PATH[1] = “/new/path” in Julia1.3.1/etc/julia/startup.jl to only affect the new version?

Thanks in advance

You should copy and paste the file .\julia\environments\v1.0\Project.toml to .\julia\environments\v1.3\Project.toml. I always do a ] up as well after this step. This will only download packages that you need, preventing duplication.

1 Like

Quick question, ] up stands for Pkg.update() ?

Yes. It’s the package manager repl mode version of Pkg.update()

1 Like

And just to add on, there’s no need for you to worry about creating a new directory to hold packages for different Julia versions. Each (minor) version of Julia, like 1.0, 1.1, 1.2, 1.3 has a separate package environment which can be found in ~/.julia/environments. Any packages you install in 1.3 will only affect that environment, so they won’t change any behavior for 1.0.

2 Likes

Thanks for the fast answers and the insights. I had the wrong approach about it, I will read the Pkg documentation to have a better grasp the Julia package system.

I created a v1 directory, and symlink everything to it:

$ ls -l ~/.julia/environments
total 4
lrwxrwxrwx 1 tamas tamas    4 Oct  7  2018 v0.7 -> v1.0
drwxrwxr-x 2 tamas tamas 4096 Aug 20 16:43 v1
lrwxrwxrwx 1 tamas tamas    2 Oct  8  2018 v1.0 -> v1
lrwxrwxrwx 1 tamas tamas    2 Oct 23  2018 v1.1 -> v1
lrwxrwxrwx 1 tamas tamas    2 Dec 13  2018 v1.2 -> v1
lrwxrwxrwx 1 tamas tamas    2 Apr 11  2019 v1.3 -> v1
lrwxrwxrwx 1 tamas tamas    2 Aug 20 16:43 v1.4 -> v1

This way I always have the same set of packages.