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

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.

Good question.
In HPC the normal answer to this is to use the Modules environment Modules - HPC Wiki

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

1 Like

Here, the result:

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/...

$ 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 --version
julia version 1.7.2
$ 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.


Thanks, trahflow, in the terminal there is only one Julia version in usr/bin/jul*:
Probably it is the LTS version, since I followed the guide on How uninstall the LTS version, for instance, will be a fast solution to my problem.

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

$ which 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 :):

$ echo $PATH
1 Like

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


You can find where that version of Julia originates from:

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

1 Like

Here, didn’t know version 1.7.1 was in /usr/bin/julia

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

If you use juliaup, that is quite simple:

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
1 Like

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)


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?

1 Like

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

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.

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