How do I add [1.5.3] to VS code in Ubuntu?

As I suspected. When Julia is asking for a executable path … don’t put an export statement there. That’s obviously not a path. A path in Linux is in the form /home/user/folder1/folder2/.... And export is a linux command, nothing to do with VScode or Julia.

In Linux when you type in julia or any other command/executable, Linux needs to know where this executable exists on the file directory. It traverses through a variable called $PATH which contains a list of common directories that include binaries/executables. The default folders it searches are often /usr/local/bin, /usr/bin. In fact you can see all the folder it searches by running

affan@XPS13:/mnt/c/Users/affan$ echo $PATH
/home/affan/anaconda3/bin:/home/affan/anaconda3/condabin:/home/affan/.rbenv/plugins/ruby-build/bin:/home/affan/.rbenv/shims:/home/affan/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files (x86)/WinSCP:/mnt/c/Program Files/dotnet:/mnt/c/Users/affan/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/affan/AppData/Local/Programs/MiKTeX 2.9/miktex/bin/x64:/mnt/c/Users/affan/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/affan/perl/perl/bin:/mnt/c/Users/affan/AppData/Local/Julia-1.3.0/bin:/snap/bin

So when you type in julia no matter where you are in the file system, Linux needs to know where the binary actually is. We accomplish this by using the command export, which essentially defines a variable in bash. So in your terminal (assuming you have bash), you can run

 export PATH="/home/affan/path/to/julia/bin:$PATH"

Note the $PATH at the end, which essentially takes the old $PATH and appends your julia folder on top. If you just run export PATH="/home/affan/path/to/julia/bin" without the $PATH append, you are going to severely break your system. If you do this successfully, you should be able to just type in julia in your terminal and it should just launch (and infact sets the pwd to that directory, which is handy).

From a VSCode point of view, now you don’t really need to do anything. The VScode extension automatically uses $PATH to find the julia binary, so you can leave it blank. Ofcourse, if you don’t do the above and do not modify your $PATH variable, then you’ll need to explicitly tell the vscode extension where julia is. I would highly recommend just setting the path once and for all.

We are not done yet. By typing in export PATH="/home/affan/path/to/julia/bin:$PATH" in your terminal, you are only changing the variable for that particular instance and will lose the modified variable the next time you login to your terminal/restart your computer. So we need a way to automatically run this command whenever you login/start your computer. Enter the file .bashrc in your home directory which is a special file that is run automatically everytime you open terminal/bash. You can edit this file and copy/paste the command export PATH="/home/affan/path/to/julia/bin:$PATH" so that you don’t have to keep doing it anymore.

If you are using zsh or some other shell, you have to put the export statement in the correct start-up file, instead of .bashrc. However, I don’t think you need to worry about this.

Other ways to accomplish similar things is not modifying your $PATH but creating a symlink in /usr/local/bin (which is already in $PATH by default). As far as I am aware, this is the canonical location for user downloaded binaries, but this might be a little too advanced for now. Just stick with setting the path correctly.

1 Like