How do set Julia version in VSCode when using juliaup

I am using Juliaup to manage my Julai version. It is now using the 1.10 beta by default. However, for one application, I need to quickly run something in 1.9. I almost exclusively use VSCode.

Is there a way, when using Juliaup, to start a VSCode session using a specific Julai version? I guess I could reconfigure Juliaup to change its default, but I am also running other julia sessions, so it would be neat if there is a way to simply tell VSCode “use this version” (like I can do with e.g. a Jupyter notebook in VSCode).

Not exactly what you want, but running:

juliaup default 1.9

in the command line before opening VS Code should do the trick.

UPDATE: this doesn’t work, see: How do set Julia version in VSCode when using juliaup - #8 by davidanthoff

1 Like

There is

julia.executablePath

in the settings of the VSCode Julia extension.
You can set it, e.g. to:

c:\Users\oheil\.julia\juliaup\julia-1.10.0-beta2+0.x64.w64.mingw32\bin\julia.exe

Choose your path to your desired Julia executable. My example is for Windows.

1 Like

Does this work for JuliaUp though? EIther case, it seems like I would have to go in, change the executive file, and then start VSCode, and then change it again?

Yeah, this would work, but feels like there might be something more convenient (just like juliaup lets you star ta Julia session without changing the default).

In my example I choose a specific juliaup installed executable.

You can start a specific version also with, e.g.

julia +1.10

but I don’t know if this is somehow configurable in VSCode in a convenient way.

1 Like

Ok, yeah, that make sense now, sorry for the confusion!

So, I think setting julia.executablePath to something like julia +1.9 should work.

What does not work (but really should) is that the VS Code extension picks up Juliaup directory overrides or the env var. That is a bit of a shame, and I hope to fix that sometime soon.

6 Likes

Ok, at least good to know. Hopefully some neater interface for these appear some time down the line :slight_smile:

1 Like

Slight improvement: I update juliaup default and then I reload the VSCode window from the command palette

1 Like

Yeah, that’s what I have been doing as well. However, that requires me to then reset the default for when I need to restart my other julia sessions (which I run in my standard environment). And then when I need to restart this julai session I have to run through it all as well.

It works, but it is a bit of a mess to keep track of.

1 Like

What worked for me is using the shell to enter the correct version, and installing any package. This creates an environment which vscode should be able to detect once you reload.

1 Like

EDIT: You also need to set the executablePath setting to explicitly point to juliaup, e.g. "julia.executablePath": "/Users/fred/.juliaup/bin/julia",

As of Dec 2024, there’s a much easier way to do this. Simply run juliaup override set 1.9 in your directory and then the julia command will use version 1.9 when run from that directory, regardless of how you start julia.

docs

1 Like

thanks for sharing this. I executed the following command in my project directory folder and get:
PS C:\Users\james\documents\sienna\fpa_sienna\nve_env> juliaup override set 1.10.4
Override set to ‘1.10.4’ for ‘\?\C:\Users\james\Documents\Sienna\FPA_Sienna\nve_env’.

however, when i call up my julia REPL in VSC via the alt + j + o cmd it still pulls up julia 1.11.2.
i have a blank entry for my julia executable file path location in vsc.

I also tried putting in a .julia-version file in the same folder location of my .toml files but thats not getting recognized by vsc either

Sorry; I forgot I had set up some hacky stuff to manage my own julia sessions, so my solution won’t work for others (I edited my post)

Sorry again; turns out the fix does work in general (I think) as long as you set the executablePath to point to juliaup—see edited post.

Thanks! I tried implementing this but wasnt successful. It doesnt look like i have the same juliaup installation setup as you because i have the following files stored at C:\Users\james.julia\juliaup

I belive this is because I dont have juliaup directly on my path but is directly callable from windows powershell command due to “aliases”

I execute: (Get-Command juliaup).Source to get the location of my juliaup.exe file.

i set my julia executable path in vsc:
“julia.executablePath”: “C:\Users\james\AppData\Local\Microsoft\WindowsApps\juliaup.exe”,

however, unfortunately that still doesnt work (i.e. its calling the release version of julia instead of the older one that i want). note i confirmed that juliaup override is working properly via “juliaup override status”. the right version of julia comes up when i activate a repl outside of vsc. it’s just not working when i am trying to run code through vsc. pretty frustrating.

if anyone has an answer to this, i greatly appreciate input. but otherwise i give up and will just manually change the path whenever i work on this specific project requiring an older version of julia