Reputation: 16074
How do I "fix" a package at particular version? in Julia?
So that we don't have to update a package if it breaks existing code.
Upvotes: 2
Views: 4797
Reputation: 3423
This question has been answered in How to pin a package to a certain version using Julia 0.7? for Julia 0.7. The following can be used in Julia 1.0 (and 0.7 it seems).
using Pkg
Pkg.add(PackageSpec(name = "GDAL", version = "0.1.2"))
Pkg.pin(PackageSpec(name = "GDAL", version = "0.1.2"))
or in the REPL package mode
julia> ]
pkg> add [email protected]
pkg> pin [email protected]
Note that if you use PackageSpec
, then only using Pkg.add
will install the correct version (tested with Docker Image "julia:1.0.5-buster").
Upvotes: 3
Reputation: 18580
After v1.0
My original answer to this question is now syntactically outdated. @RikH has provided an answer with the latest syntax. For additional info beyond that answer regarding the syntactical differences between working in the REPL package mode or the regular REPL, type using Pkg
, and then ?Pkg.PackageSpec
at the REPL to see examples of the ways in which package versions/commits etc can be referenced
Before v1.0
The process for doing this is described pretty clearly in the official docs. However, I suspect this question will be searched for frequently, so perhaps it doesn't hurt to double up.
Packages can be pinned to a specific version using Pkg.pin
. The single input method will pin the package to the current version:
julia> Pkg.pin("DependentBootstrap")
INFO: Creating DependentBootstrap branch pinned.b32df31a.tmp
julia> Pkg.status()
13 required packages:
...
- DependentBootstrap 0.1.0 pinned.b32df31a.tmp
- ForecastEval 0.1.0
where you'll note the package has been pinned to a specific git commit.
You can pin to a specific tagged version of a particular package using a second argument:
julia> Pkg.pin("DependentBootstrap", v"0.0.1")
INFO: Creating DependentBootstrap branch pinned.996d3c22.tmp
INFO: Downgrading ForecastEval: v0.1.0 => v0.0.1
INFO: Building SpecialFunctions
INFO: Building Rmath
julia> Pkg.status()
13 required packages:
...
- DependentBootstrap 0.0.1 pinned.996d3c22.tmp
- ForecastEval 0.0.1
Notice that the pinning operation automatically downgraded ForecastEval
in order to satisfy version requirements.
You can get the package back to the latest stable version using Pkg.free
:
julia> Pkg.free("DependentBootstrap")
INFO: Freeing DependentBootstrap
INFO: Upgrading ForecastEval: v0.0.1 => v0.1.0
INFO: Building SpecialFunctions
INFO: Building Rmath
julia> Pkg.status()
13 required packages:
...
- DependentBootstrap 0.1.0
- ForecastEval 0.1.0
Notice that ForecastEval
has also automatically returned to the latest version.
Upvotes: 6
Reputation: 1
For the last update of pkg package, the accepted answer no longer works.
You must specify the version after the @ symbol. pin [email protected]
(v1.1) pkg> pin [email protected]
Resolving package versions...
Installed CSV ─ v0.4.2
Updating `C:\Users\S\.julia\environments\v1.1\Project.toml`
[336ed68f] ↓ CSV v0.4.3 ⇒ v0.4.2 ⚲
Updating `C:\Users\S\.julia\environments\v1.1\Manifest.toml`
[336ed68f] ↓ CSV v0.4.3 ⇒ v0.4.2 ⚲
⚲ means that the version is sucsesfully pinned.
Updated link to the official manual
Upvotes: -2