Building multiple versions of Julia

Currently I have 2 versions of julia in my system, v0.5.2 and v0.7.0-DEV (master). To do so I cloned twice the repository to different folders and I build them to have both versions.

I think that it should be a way of downloading the repository only once and somehow do a git checkout master to some folder and git checkout v.0.5.2 into some other folder from which later I can build.

Any suggestion? Thank you

I don’t know whether this can be done. But note that it wouldn’t buy you much in terms of saving diskspace. The size of the cloned Julia repo is 0.2GB, but once you build it, it is 3GB. Much of this is due to external libraries, which often will be on different versions for different Julia versions. Thus sharing them between two Julia version will be difficult. But maybe someone has a trick?


Well, first you should check the link provided by @yuyichao.

I am just posting one solution to answer your question (on a *nix machine):

  1. Clone the repository.
    git clone ~/julia-repo.
    This command will clone the repository to the julia-repo folder in your user’s home folder.
  2. After cd ~/julia-repo, checkout your favourite tag as a new branch.
    git checkout -b install-0.5 v0.5.2
    This will create a new branch named install-0.5 from the tagged commit v0.5.2, which is the latest stable patch in v0.5 series.
  3. Follow the steps on the Julia website to install the corresponding version.
  4. Clean the workspace by issuing make cleanall or similar command. Once you are in ~/julia-repo folder, you can git clean -fdx to (force) clean all the untracked files and folders, i.e., the dependencies. For more info on what the -fdx switch means, please issue git help clean.
  5. You can keep the branch, or simply remove it if you want: git branch -d install-0.5.
  6. Some time after, when you would like to fetch the new updates from the repo, do the following:
cd ~/julia-repo
git checkout master
git fetch --all --prune
git merge --ff-only origin/master # if this results in a conflict, you are doing something wrong.
# if that is the case, issue first the below command prior to git merge
git reset --hard --

Follow steps 2-5 for other versions such as v0.6.0-rc3, master (for the latest (probably unstable) release), etc., as in

cd ~/julia-repo
git checkout -b latest master
# or,
# git checkout -b install-0.6 v0.6.0-rc3

I hope this solves your problem.


P.S: You can find all the tags by issuing git tag inside ~/julia-repo.

Sure, I did check the link of @yuyichao. It is very interesting. There are many things to learn each single day. I like both solutions, and now I’m implementing this ideas into a script.

Thanks a lot

See also (cc @pmargreff)

1 Like

Note: Using juliavm you’ll be able to use only already released versions, v0.7.0-DEV version wasn’t released yet.

I use make install, with a particular prefix (set in “Make.user”), each time I want to keep a certain version. This surely saves space compared to building in different clones (an installed julia takes up about 200MB). This seems simpler than using git worktree.
It it can be of any help, to automatically set the prefix, I have this in my “Make.user”:

BRANCH=$(shell git rev-parse --abbrev-ref HEAD | sed s-/-_-)
COMMIT=$(shell git rev-parse HEAD | cut -c 1-8)

prefix = $(shell echo $(ROOTPREFIX)$(BRANCH)_$(COMMIT))
1 Like

With git-worktree, do you have a way to avoid rebuilding the whole deps directory in a new working tree? I tried to symlink deps/srscache and deps/scratch (the two biggest subdirectories) from the main worktree, but this errors out.

Probably, but I don’t. I use system version of most dependencies to avoid this problem ;-p


Thanks for the hint!