Working with different versions of Julia

Under normal circumstances, I work with a single version of Julia, say, Julia 1.8. I have a folder of Julia code, along with Project.toml and Manifest.toml files. I would also like to work with Julia 1.9. What is the strategy? Create a second folder with its own toml files (the Manifest contains the Julia version in its first line). If I create a second folder with code and toml files, I no longer have a single version of my code. What is the solution? I want to maintain a single version of my Julia code but run it with different versions of Julia. I am working with Visual Studio Code. Thanks for any insight.

2 Likes

Two folders and just linked file code ?

I mean something like “ln -s” for example.

Just a suggestion. I do not know.

I actually used a regular link (so that I could delete one or the other file without adverse consequence. However, the approach is not satisfactory to me. Since the Manifest contains the version of Julia on the first line, I would prefer either that the julia version be appended to the Manifest name, for example, `Manifest_1_9.toml, or a single manifest file that contains data for multiple Julia instances.

I like the tool asdf for managing different versions of programming languages. It has a Julia plugin available here.

Once you have both asdf and the julia plugin installed, you can do the following:

asdf install julia 1.8.5
asdf install julia 1.9.0-rc2
asdf global julia 1.8.5
asdf local julia 1.9.0-rc2
asdf reshim

This will download julia versions 1.8.5 and 1.9.0-rc2 in an asdf-managed directory, set the global julia version to be 1.8.5, and set the version of julia used in the current local directory (manged with a .tool-version file) to be 1.9.0-rc2.

I don’t use VS Code, so I’m not sure how well this works for your case, but others might know.

First, not considering the VSCode part, you can create a directory associated with each julia version, for example:

MyPkg_Julia1.9
#and
MyPkg_Julia1.6

then start Julia with the appropriate version within each folder, activate the environment of that folder, and dev MyPkg there.

I don’t know if you can use different Julia versions at the same time in VSCode, I know you can switch versions by closing VSCode and restarting it, and the easiest way I know for that is involving juliaup:

Install two different versions of julia with juliaup, and you can switch which is the default version using

juliaup default 1.9
#or
juliaup default 1.6

and then the next time you start VSCode the default version will be the one used (if you left the julia executable path empty in the extension settings, which is what I do).

Combining both things it is possible to have a reasonably practical way to work with two Julia versions, at least in an alternating way.

2 Likes

As for the different versions of Julia, juliaup is the easiest tool. As for the different versions of a package, I would recommend two branches of a git project?

Thank you all for your suggestions. At this time, I create two folders, one per julia version, and simply make sure the same Project.toml is in each folder. I then use symbolic links. Git branches are also a good solution for me. Thanks!