The context is not entirely clear but guessing that you want to get a rather recently registered version you could look into the βeagerβ package server option. See 7. Registries Β· Pkg.jl.
Iteresting. But no, I just want to know how I can explain to my students or partners how to install the latest, released version of my package, assuming the package servers have finished their update.
I could do:
using Pkg
pkg"add KiteModels"
pkg"update"
But is that the best way to do it?
It might precompile first the old version and then the new version. It might also update other packages than KiteModels even if that is not required.
Do you have the env variable JULIA_PKG_PRESERVE_TIERED_INSTALLED set? Otherwise the default should be to install the latest version, assuming it doesnβt conflict with another package, and assuming the registry is up-to-date (and the registry will by default update on the first pkg operation of the julia session, or when update is called).
No, the default is tiered, and that does NOT install the latest version:
Argument Description
ββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
installed Like all except also only add versions that are already installed
all Preserve the state of all existing dependencies (including recursive dependencies)
direct Preserve the state of all existing direct dependencies
semver Preserve semver-compatible versions of direct dependencies
none Do not attempt to preserve any version information
tiered_installed Like tiered except first try to add only installed versions
tiered Use the tier that will preserve the most version information while
allowing version resolution to succeed (this is the default)
Perhaps this command would install the latest version:
Tiered tries to not change other existing versions, but in your example you are creating a new environment and adding KiteModels to it (alone) so there are no other versions to preserve. Thatβs why Gunnar is asking you about registry eagerness and Iβm asking about ENV variables; it sounds like something else is happening or something is going wrong.
I have no Julia related env variables. I just had an old version - in a different project - installed before. I think Pkg re-uses packages from other project and doesnβt install and precompiles them again if you start a new project.
$ mkdir /tmp/testdepot # Create an empty depot.
$ JULIA_DEPOT_PATH=/tmp/testdepot julia # Start Julia 1.10.4 like freshly installed.
(@v1.10) pkg> add KiteModels@0.6.3 # Add 0.6.3 to global environment.
julia> using KiteModels # Load it for good measure.
(@v1.10) pkg> activate --temp # Create an empty environment.
(jl_kSO7yU) pkg> add KiteModels # Add KiteModels, installs 0.6.4.
#!/bin/bash -eu
rm -rf /tmp/testdepot
mkdir /tmp/testdepot
rm -rf /tmp/test
mkdir /tmp/test
cd /tmp/test
export JULIA_DEPOT_PATH=/tmp/testdepot
julia --project="." -e "using Pkg; pkg\"add KiteModels#v0.6.3\"; using KiteModels"
cd ..
rm -rf /tmp/test2
mkdir /tmp/test2
cd /tmp/test2
julia --project="." -e "using Pkg; pkg\"add KiteModels\"; using KiteModels; pkg\"status\""
cd ..
It indicates that Pkg.add installs the latest version of my package under the given test conditions.
So perhaps I had an outdated registry. Where is the registry stored? Is there one registry stored per project, or one per Julia depot? When does Julia fetch a new version of the registry? Is there a command to force that?
The registry is usually stored in the depot. The default location is ~/.julia/registries/.
See the registry update command.
(@v1.10) pkg> help registry update
registry [up|update]
registry [up|update] reg...
Update package registries reg.... If no registries are specified all
registries will be updated.
Examples
pkg> registry up
pkg> registry up General
A question Iβve asked myself a few times and which seems closely related enough that I donβt think Iβm hijacking the thread here:
Is there a command to simply get latest released version of a package? I normally just check GitHub manually, but would be interested to hear about programmatic solutions.