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

I downloaded 1.6.0 into a file called Julia in my home directory.

I tried to enter

export PATH="$PATH:/path/to/~/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin"

into VS Code, so it would find this file, but instead it says it can’t find the directory.

The terminal process failed to launch: Path to shell executable "export PATH="$PATH:/path/to/~/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin"" does not exist.

This should be replaced with ~/ since this current directory doesn’t point to your home. I’m not sure if vscode properly expands ~, so you could also try $HOME.

1 Like

like this:

export PATH="$HOME:~/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin"

now it’s saying:

Could not start the julia language server. Make sure the configuration setting julia.executablePath points to the julia binary.

Sorry, I wasn’t very clear. If you are doing development in Julia using the Linux shell, I believe the correct export command for you is

export PATH="$PATH:$HOME/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin"

The $HOME environmental variable just expands to the path of your home directory. The part at the beginning with$PATH: causes the export to append to, rather than overwrite, your PATH.

Since you’re doing development in VS Code, you might have to set up the correct path for the language server to find. In your VS Code settings JSON file (there is a button in the top right corner of the settings interface), you can specify the executable path for the language server. For example, here is an excerpt from my settings file, modified to what I believe is your setup.

  "julia.enableTelemetry": true,
  "julia.executablePath": "${env:HOME}/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin/julia",
  "julia.NumThreads": 6,

FWIW, the language server doesn’t support 1.6 atm.

What about 1.5.3?

Works fine.

Ok thanks, I get the Path I think, what do I put in the JSON?

I’m still getting the same error as before. I went to the bin folder, and it contains an executable file. is this the right folder, or do I need to find a folder with a .bin file?

I just found this error

Command failed: "export PATH="$PATH:$HOME/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin"" --startup-file=no --history-file=no -e "using Pkg; println.(Pkg.depots())"
/bin/sh: 1: export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/brett/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin: not found
 `"export PATH="$PATH:$HOME/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin"" --startup-file=no --history-file=no -e "using Pkg; println.(Pkg.depots())"` (exited with error code 127)

what files should be in the folder that I’m connecting to?

Could you post your .bashrc or wherever you have the export command saved? Also could you post your VS Code settings (Click File -> Settings) and show us your Julia executive path variable?

It seems like you put the verbatim command export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/brett/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin in the executable path variable of VScode, which is completely wrong.

Here are two solutions.

  1. add an export statement to your .bashrc so that the Julia folder is in PATH as soon as you login to bash. Then if done properly, you don’t really need to fill in the executable path variable in VSCode.

  2. Ignore the export part (but you’ll lose the ability to simply type in julia anywhere in bash to launch). In this case, simply add the correct path to the executable path variable in VSCode.

In summary, either you allow vscode to find Julia by going through the $PATH variable (which is what I would suggest) or you manually tell VScode where your Julia is by filling in the executable path variable in VSCode… I don’t think you need to do both.

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

So does that mean I put

export PATH="~/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin:$PATH"

in the terminal to create a path to VS Code? (if it allows 1.6 beta, else)

export PATH="~/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin:$PATH"

and then leave the executable path empty?

Yes. Properly set up your path and leave the executable path empty. I’d also just advise sticking with 1.5.3 for now since the vscode extension is not updated for 1.6. If you do want to have both julia, you can do

export PATH="~/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin:~/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin:$PATH"

now, here is an exercise for the reader. Both the paths ~/Julia/julia-1.5.3-linux-x86_64/julia-1.5.3/bin and ~/Julia/julia-1.6.0-beta1-linux-x86_64/julia-1.6.0-beta1/bin contain a binary called julia… so when you type in julia in the terminal, which one will it launch? 1.5.3 or 1.6? Try it out and let me know :slight_smile:


But when I type in the REPL :

julia> ]

it becomes


should I have a 1.5.3 extension from the marketplace?

Are you sure you are launching 1.5.3? You may be launching 1.0.x as the binary for that version is likely whats being launched. This could happen if the path for the 1.0 version takes precendent in $PATH. What does versioninfo() say from the vscode terminal repl and also a regular terminal.

I launched 1.5.3 in the terminal, I don’t see the opening screen in VS Code, I think it’s either 1.0.4 or 1.0.10 .

You can launch julia in vscode by executing the command “start REPL” in vscode. I don’t know know the shortcut for linux, but for windows its “ctrl-shift-p” to bring up command launcher.

Linux it’s F1. I got that part, I just wasn’t sure how to select the version to run.