Installing Julia on ubuntu, julia not found?

I have downloaded the tar.gz and extracted it in downloads. Just to try running Julia in terminal, I navigated to the bin folder and typed in ‘julia’, but no such command was found. I tried clicking the julia file, and nothing happens. Unfortunately the instructions on the download page for ubuntu have not been particularly illuminating with regard to how to get julia up and running after extracting the tar (I’m not quite sure how to change path environment variables and it seems complicated, I could create a symbolic link but it seems that the julia in the bin is itself not doing anything either).

Does anyone have details as to how I can install julia and get it to run in my terminal just by typing ‘julia’, after extracting the .gz folder?

Thanks

If you are in the bin folder you need to do ./julia.

To make it run by just typing julia you can either do alias julia="/home/user/path/to/julia/bin/julia" in your .bashrc, add /home/user/path/to/julia/bin/ to your PATH environment variable or create a symlink to the julia executable to somewhere that is in PATH e.g. sudo ln -s home/user/path/to/julia/bin/julia /usr/bin/julia.

5 Likes

I found a solution to this with the following:
I entered sudo gedit /etc/environment into the terminal, then entered the path to my bin folder (separated from the other paths with a : and still within the quotes.

This allowed me to run by just typing in julia into the terminal.

Hello @samantp We all know how you are feeling. In the early days of using Linux/Unix systems a person is full of enthusiasm - they want to do great things quickly.
Then frustrating issues like this happen.
But Bon Courage!
a) everyone her will help you. DO not stop using Julia
b) every issue like this helps you to learn

1 Like

By the way, editing the /etc/environment is fine.
But what happens when you upgrade your Julia version?
The next step in out journet is learning how to use links.
For instance on my Ubuntu laptop:
/usr/local/julia-1.3.0
Then /usr/local/julia is a link to julia-1.3.0

1 Like

@samantp, I described how to set the environment variable in this video from minute 5:27. It’s in german language, but with the text it’s pretty clear. Good luck!

1 Like

The next stage in the journey is to forget about using links and to start using the Modules environment.
OR we can open the discussion of flatpak/snaps again

But I am digressing - the message is we are all ready to support you.
And we look forward to hearing about the great work you will do with Julia

If you want to better understand how programs are found when you type name and execute it, this is a nice explanation of the Linux (and UNIX in general) PATH environment variable: What is PATH? -- definition by The Linux Information Project (LINFO).

3 Likes

I tried a few things but that worked best. Add the following statement to .bashrc

export PATH=$PATH:/yourpath/julia-1.3.1/bin

best regards
Michael

2 Likes

Another consideration:
migrating code to julia 1.x leads to also installing julia 0.7:
run code in julia 0.7 and look at the suggested changes.

One way to deal with this is to have an alias, e.g.,
alias j7='path_to_julia0.7_bin/julia
in addition to your choice for having a julia command.

Alternative: use the CDPATH variable to quickly move to a specific directory,
so you can run some program in that directory…

According to /etc/skel/.profile (the template that the system uses when it creates a new user home directory) on Ubuntu 19.10, $HOME/bin and $HOME/.local/bin are automatically added to the user’s PATH environment variable. This is also true for Debian Buster as installed in Crostini. So, if no one has mangled $HOME/.profile, then those directories will already be searched for executable programs if they are present when the user logs in.

The following shell commands will install julia-1.3.1 into ~/.local/bin for an x86_64 linux. You may need to login for the install to take effect, and you may need to install the curl command using sudo apt install curl

DIR=~/.local/bin
URL=https://julialang-s3.julialang.org/bin/linux/x64/1.3/julia-1.3.1-linux-x86_64.tar.gz
mkdir -p $DIR
cd $DIR
curl -o - $URL | tar xzf -
ln -s julia-*/bin/julia .

This is good for an initial installation, the final ln -s command will need more thought if you install more than one version of julia.

1 Like

May be it’s not a good idea to put whole Julia folder in ~/.local/bin/, usually it’s better to keep only executables there. This is user purely user’s choice, it’s just easier to manage it.

One could keep Julia in ~/julia/ for example and symbolic link executable to ~/.local/bin:
ln -s ~/julia/julia-1.4/bin/julia ~/.local/bin

3 Likes

Does this solution work after we update julia ?

I would suggest using jill.py to install Julia on Linux. Simplifies the process greatly!

Just wanted to add that after adding julia bin directory to PATH,

export PATH="$PATH:/path/to/<Julia directory>/bin"

we need to log out and on for changes to take effect. I was stuck there for some time.

1 Like

Make sure it’s a full path as you show. While you CAN run julia without a full path from the shell, you may run into trouble in other contexts (e.g. related to PyCall, and TopLoader from python), as

$ which julia

will not find julia otherwise (if you use “~” tilde letter). It took me a while to find this out (so I documented it on julia website), but it seems intentional (I guess a security issue), as man which has “It does not canonicalize path names.”

If you add to PATH in .bashrc (and .bash_profile didn’t work at all for me) then yes, you would have to login again, but doing your way (only) in the shell works without logging out (would be a temporary fix).

1 Like