In this post, we will see how to resolve Install a local package in the default environment with project.toml dependency
Question:I want to install a local package (let’s say foo.jl) in the default environment because I don’t want to activate the package environment (
Pkg.activate("\path\to\foo.jl")) every time.
However, when I try to install the package by
Pkg.add(path=\path\to\foo\), it seems that the project.toml of the foo.jl was not followed. Specifically, foo.jl requires
"JuMP=1.5.0"in the project.toml compatibility module, but
"JuMP=1.9.0"was installed and was added to the project.toml of the default environment.
Could anyone please explain how the process works? I know I can use “instantiate” to reproduce the environment, but it creates a project environment and installs the package instead of installing the package in the default environment.
Best Answer:Julia uses semantic versioning for package compatibility.
If you write
JuMP="1.5.0"the acceptable version include
[1.5.0 - 2.0.0)(note that the range is open on the right side). Since 1.9.0 is currently the latest version, it gets installed and this is the correct expected behavior.
Most likely what you wanted is:
The way you are adding the packages seems to be correct.
For more details on semantic versioning see: https://pkgdocs.julialang.org/v1/compatibility/
If you have better answer, please add a comment about this, thank you!