- I installed Julia 1.6
- I installed the latest MLJ 0.16
- I installed NaiveBayes.jl but got downgraded to MLJ 0.15.2 without my consent!
Is this non-consentual downgrading intended?
- If this is the wrong place please redirect me to the appropriate thread …
julia> Pkg.add("NaiveBayes")
Resolving package versions...
Installed GPUCompiler ─ v0.9.2
Installed CUDA ──────── v2.6.0
Updating `~/.julia/environments/v1.6/Project.toml`
[f6006082] ↓ EvoTrees v0.7.0 ⇒ v0.5.3
[add582a8] ↓ MLJ v0.16.0 ⇒ v0.15.2
[d491faf4] ↓ MLJModels v0.14.1 ⇒ v0.13.3
[9bbee03b] + NaiveBayes v0.5.0
Yes, it is intended, and it is consensual: you executed a function (Pkg.add
) without reading the documentation. You can pass a keyword parameter to the function to force it to avoid any downgrading.
julia> using Pkg
help?> Pkg.add
Pkg.add(pkg::Union{String, Vector{String}}; preserve=PRESERVE_TIERED)
Pkg.add(pkg::Union{PackageSpec, Vector{PackageSpec}}; preserve=PRESERVE_TIERED)
Add a package to the current project. This package will be available by using the
import and using keywords in the Julia REPL, and if the current project is a
package, also inside that package.
Resolution Tiers
==================
Pkg resolves the set of packages in your environment using a tiered algorithm. The
preserve keyword argument allows you to key into a specific tier in the resolve
algorithm. The following table describes the argument values for preserve (in
order of strictness):
Value Description
––––––––––––––– –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
PRESERVE_ALL Preserve the state of all existing dependencies (including recursive dependencies)
PRESERVE_DIRECT Preserve the state of all existing direct dependencies
PRESERVE_SEMVER Preserve semver-compatible versions of direct dependencies
PRESERVE_NONE Do not attempt to preserve any version information
PRESERVE_TIERED Use the tier which will preserve the most version information (this is the default)
Examples
≡≡≡≡≡≡≡≡≡≡
Pkg.add("Example") # Add a package from registry
Pkg.add("Example"; preserve=Pkg.PRESERVE_ALL) # Add the `Example` package and preserve existing dependencies
Pkg.add(name="Example", version="0.3") # Specify version; latest release in the 0.3 series
Pkg.add(name="Example", version="0.3.1") # Specify version; exact release
Pkg.add(url="https://github.com/JuliaLang/Example.jl", rev="master") # From url to remote gitrepo
Pkg.add(url="/remote/mycompany/juliapackages/OurPackage") # From path to local gitrepo
Pkg.add(url="https://github.com/Company/MonoRepo", subdir="juliapkgs/Package.jl)") # With subdir
See also PackageSpec.
8 Likes
Thanks for referring me to the docs.
The current default option is: preserve=PRESERVE_TIERED
By “consent” I mean avoiding a default option for package resolution and instead asking the user to select an option in REPL.
Or maybe keep the default option in Pkg.add
as is (with current warnings), but tell the user in Pkg.status()
which package version is in the current environment and which version is the latest:
(@v1.6) pkg> status
Status `C:\Users\azevelev\.julia\environments\v1.6\Project.toml`
Package Current Latest
[f6006082] `EvoTrees v0.5.3 v0.7.0`
[9bbee03b] NaiveBayes v0.5.0 v0.5.0
[add582a8] `MLJ v0.15.2 v0.16.0`
[d491faf4] `MLJModels v0.13.3 v0.14.1`
And highlight (in a different color?) which packages in the current environment are not the latest.
I think package resolution is one of the most common challenges faced by newcomers to Julia.
It would help if there was a standard parsimonious tutorial introducing package management to newcomers.
7 Likes