# Two versions of Julia installed. How to use the latest as default when executing a code?

**URL:** <https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703>\
**Category:** New to Julia\
**Created:** [February 18, 2022, 3:22pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703 "2022-02-18T15:22:09Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![munizalex](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@munizalex](https://discourse.julialang.org/u/munizalex)\
**Post date:** [February 18, 2022, 3:22pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/1 "2022-02-18T15:22:09Z")

</div>

Here, finally installed everything I need on my new fresh Fedora 35 install, and I made a mistake to install LTS version **and** fedora repo of Julia. How do I set the latest as default, like in the terminal run “julia 1.7.1 code.jl”?  
No pressure, I will start studying only on March 7, I just need everything sort out until then. And thanks, Julia deserves more adoption of programmers.

 ![2022-02-18_12-12](https://global.discourse-cdn.com/julialang/original/3X/f/5/f54d52382b68df2a3ced0fa21bb0eb8eb4dc0ca4.png)

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 18, 2022, 3:28pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/2 "2022-02-18T15:28:35Z")

</div>

Good question.  
In HPC the normal answer to this is to use the Modules environment [Modules - HPC Wiki](https://hpc-wiki.info/hpc/Modules)

Here I would just define the JULIA\_HOME environment variable before running Julia  
Could you run rpm -q -a | grep -i julia please?  
I have a Fedora laptop and can probably replicate your environment

---

<div class="post-metadata">

**Author:** ![munizalex](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@munizalex](https://discourse.julialang.org/u/munizalex)\
**Post date:** [February 18, 2022, 3:31pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/3 "2022-02-18T15:31:23Z")

</div>

Here, the result:  
 ![2022-02-18_12-30](https://global.discourse-cdn.com/julialang/original/3X/f/4/f4f7235b0da4df4648257853af33a28e44b0ce8d.png)

---

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [February 18, 2022, 3:34pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/4 "2022-02-18T15:34:48Z")

</div>

What I do:

I install the latest release of julia via my _distro’s package manager_ (Note: I’m on arch linux, which basically always gives me the latest release. Generally I would not recommend installing via the distro’s package manager. See below).  
In addition I also install the LTS version _manually_ (as explained on the Julia/Installation page) in `/opt/julia`.  
Then I add a symlink `usr/bin/julia-lts` that points to the manually installed LTS version binary in `/opt/julia/...`

```julia
$ ls -l /usr/bin/jul*
-rwxr-xr-x 1 root root 12552 8. Feb 11:05 /usr/bin/julia
lrwxrwxrwx 1 root root 32 22. Dez 10:23 /usr/bin/julia-lts -> /opt/julia/julia-1.6.5/bin/julia

```

I can then use the two different versions as:

```julia
$ julia --version
julia version 1.7.2

```

```julia
$ julia-lts --version
julia version 1.6.5

```

For other distros I would generally recommend to not install julia via the distro’s package manager, but install **all desired versions manually** by putting them in (e.g.) `/opt/julia/julia-1.6.5`, `/opt/julia/julia-1.7.1` etc. and then just creating symlinks from those version-specific julia binaries in `/usr/bin`.

---

<div class="post-metadata">

**Author:** ![munizalex](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@munizalex](https://discourse.julialang.org/u/munizalex)\
**Post date:** [February 18, 2022, 3:45pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/5 "2022-02-18T15:45:01Z")

</div>

Thanks, trahflow, in the terminal there is only one Julia version in usr/bin/jul\*:  
 ![2022-02-18_12-38](https://global.discourse-cdn.com/julialang/original/3X/3/f/3fc32853cd0421482c51f3ced02d62cebda625a6.png)  
Probably it is the LTS version, since I followed the guide on [julialang.org](http://julialang.org). How uninstall the LTS version, for instance, will be a fast solution to my problem.

---

<div class="post-metadata">

**Author:** ![trahflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/trahflow/32/30585_2.png) [@trahflow](https://discourse.julialang.org/u/trahflow)\
**Post date:** [February 18, 2022, 3:51pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/6 "2022-02-18T15:51:11Z")

</div>

> [@munizalex](#):
>
> Thanks, trahflow, in the terminal there is only one Julia version in usr/bin/jul\*

`/usr/bin` is not the only directory/path in which the shell searches for binaries.

To figure out where the binary is located that is executed if you simply type `julia` in your shell, do:

```julia
$ which julia
/usr/bin/julia

```

The shell’s `$PATH` variable holds all the directories/paths in which it searches for binaries.  
To list all paths in `$PATH` (separated via `:`):

```julia
$ echo $PATH

```

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 18, 2022, 3:52pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/7 "2022-02-18T15:52:06Z")

</div>

I use Fedora 34, so the RPM version is 1.6.5 for me and is /use/bin/julia

I echo what @trahflow says and this is exactly what I do with Fedora.  
Download the tarball from the Julia website, put it in /tmp  
As root / sudo:  
cd /usr/local  
tar zxvf /tmp/julia-version-x86\_64.tgz (or whatever the tarball is named as)

ln -s /usr/local/julia-1.7.1 /usr/local/julia

In my .bashrc I set  
export PATH=/usr/local/julia/bin:$PATH

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 18, 2022, 3:53pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/8 "2022-02-18T15:53:10Z")

</div>

You can find where that version of Julia originates from:

rpm -q --whatprovides /usr/bin/julia

---

<div class="post-metadata">

**Author:** ![munizalex](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@munizalex](https://discourse.julialang.org/u/munizalex)\
**Post date:** [February 18, 2022, 3:57pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/9 "2022-02-18T15:57:49Z")

</div>

Here, didn’t know version 1.7.1 was in /usr/bin/julia  
 ![2022-02-18_12-55](https://global.discourse-cdn.com/julialang/original/3X/2/2/22c1eae881586031de5937e9dad22bbe7469e4c1.png)

So I have the latest and Fedora repo will update this package for me? That’s great if I am correct here

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 18, 2022, 5:16pm UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/10 "2022-02-18T17:16:35Z")

</div>

If you use [juliaup](https://github.com/JuliaLang/juliaup), that is quite simple:

```julia
juliaup add 1.7
juliaup add 1.6

% julia # will launch the latest stable version

% julia +1.6 # will launch the latest 1.6.X version

```

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 19, 2022, 1:58am UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/11 "2022-02-19T01:58:59Z")

</div>

For me, at least on Linux, simply downloading the binary from the site and creating symlinks on `/urs/bin` or `~/bin` like `julia1.5`, `julia1.6`, `julia1.7`, `julia` remains the most reliable, simple and flexible way to run Julia…  
(note that you don’t even need to be root to install it if you go with the `~/lib/` with symlinks on `~/bin/` way)

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [February 19, 2022, 3:41am UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/12 "2022-02-19T03:41:16Z")

</div>

One thing to ask - how did you install the LTS version?  
If you donloaded a tarball and unpacked it in /usr/local we might have to re-install the distro provided ROM  
Or did you unpack the tarball in your home directory?

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [February 19, 2022, 4:03am UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/13 "2022-02-19T04:03:19Z")

</div>

On Linux, I untar binaries into ~/packages, then make symbolic links

```julia
cd ~/bin
ln -s ~/packages/julia-1.7.0/bin/julia julia-1.7.0
ln -s julia-1.7.0 julia

```

When I install a new version of Julia, I change the `~/bin/julia` link to the latest version.

---

<div class="post-metadata">

**Author:** ![munizalex](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@munizalex](https://discourse.julialang.org/u/munizalex)\
**Post date:** [February 20, 2022, 3:43am UTC](https://discourse.julialang.org/t/two-versions-of-julia-installed-how-to-use-the-latest-as-default-when-executing-a-code/76703/14 "2022-02-20T03:43:28Z")

</div>

First I untar by search how to untar through terminal:`tar -xvzf julia-1.6.5-linux-x86_64.tar.gz`  
Then I sudo su and as root move the untar directory to /opt/. Then I ` ln -s /opt/julia-1.6.5/bin/julia /usr/local/bin/julia`

But I did not know how to uninstall Julia 1.6.5 or in what directory Julia from Fedora repo was installed. And since Julia is a rare language, nowhere did I see how to set up Julia 1.7.1 (now it’s 1.7.2) in the terminal or Jupyter. It was still Julia 1.6.5 that is recognized. So, **your comment** made me realize it was simple as making step 2 (the second code here) and `sudo ln -s /usr/bin/julia /usr/local/bin/julia.1.7`  
And then it works. Thanks! Mate, **it’s you who sparked this idea in me** , it was not me. If I use `julia.1.7 --version` now appears `julia version 1.7.2`
