Search code examples
juliajulia-jumptoml

How to specify julia project to use different version of JuMP depending on the julia version


How can I specify in julia project's Project.toml that a different version of JuMP should be installed with specific julia versions. I would like to use JuMP 1.3.0 but for example julia 1.0 accepts JuMP versions up to 0.22.3. I would need to thus specify that for julia version 1.0 the project would install JuMP version 0.22.3 and for higher julia versions the project would install JuMP version 1.3.0.


Solution

  • This is actually managed via the [compat] section of the Project.toml file. So normally you just do Pkg.add("JuMP") and end up having the latest possible JuMP version that matches your Julia environment.

    For an example for JuMP release 0.22 you will find in Project.toml:

    [compat]
    ...
    julia = "1"
    

    Julia uses semantic versioning. This means that this version can be installed with any Julia version >=1 but not Julia 2 (which does not exist and is not in plan of today).

    On the other hand have a look at Project.toml for JuMP 1.0:

    [compat]
    ...
    julia = "1.6"
    

    You can see that this requires at least Julia version 1.6.

    The package manager will install whatever latest package is available. You could decide to install an older package by providing the version parameter:

    Pkg.add(name="JuMP", version="1.1.0")