# Building multiple versions of Julia

**URL:** <https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 12, 2017, 1:06pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224 "2017-06-12T13:06:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iagoba\_Apellaniz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iagoba_apellaniz/32/34406_2.png) [@Iagoba\_Apellaniz](https://discourse.julialang.org/u/Iagoba_Apellaniz)\
**Post date:** [June 12, 2017, 1:06pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/1 "2017-06-12T13:06:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [June 12, 2017, 1:14pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/2 "2017-06-12T13:14:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [June 12, 2017, 1:19pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/3 "2017-06-12T13:19:32Z")

</div>

[https://git-scm.com/docs/git-worktree](https://git-scm.com/docs/git-worktree)

---

<div class="post-metadata">

**Author:** ![anon61610682](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@anon61610682](https://discourse.julialang.org/u/anon61610682)\
**Post date:** [June 12, 2017, 2:09pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/4 "2017-06-12T14:09:50Z")

</div>

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 https://github.com/JuliaLang/Julia.git ~/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:

```julia
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

```julia
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.

Cheers!

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

---

<div class="post-metadata">

**Author:** ![Iagoba\_Apellaniz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iagoba_apellaniz/32/34406_2.png) [@Iagoba\_Apellaniz](https://discourse.julialang.org/u/Iagoba_Apellaniz)\
**Post date:** [June 12, 2017, 2:28pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/5 "2017-06-12T14:28:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [June 12, 2017, 4:42pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/6 "2017-06-12T16:42:42Z")

</div>

See also [https://github.com/pmargreff/juliavm](https://github.com/pmargreff/juliavm) (cc @pmargreff)

---

<div class="post-metadata">

**Author:** ![pmargreff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pmargreff/32/698_2.png) [@pmargreff](https://discourse.julialang.org/u/pmargreff)\
**Post date:** [June 12, 2017, 5:04pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/7 "2017-06-12T17:04:18Z")

</div>

Note: Using juliavm you’ll be able to use only [already released versions](https://github.com/JuliaLang/julia/releases), v0.7.0-DEV version wasn’t released yet.

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [June 15, 2017, 5:06pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/8 "2017-06-15T17:06:39Z")

</div>

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”:

```julia
ROOTPREFIX=<custom-location>/build/julia/
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))

```

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [June 17, 2017, 11:50am UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/9 "2017-06-17T11:50:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [June 17, 2017, 11:58am UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/10 "2017-06-17T11:58:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [June 17, 2017, 12:35pm UTC](https://discourse.julialang.org/t/building-multiple-versions-of-julia/4224/11 "2017-06-17T12:35:01Z")

</div>

Thanks for the hint!
