# How to install the newest version of a package?

**URL:** <https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110>\
**Category:** General Usage\
**Tags:** question, package, pkg\
**Created:** [August 12, 2024, 9:13pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110 "2024-08-12T21:13:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 9:13pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/1 "2024-08-12T21:13:49Z")

</div>

How can I install the latest version of a package?

If I have for example KiteModels v0.6.3 installed before (in a different project) and then do:

```julia
mkdir test
cd test
julia --project="."

```

and try to install KiteModels with:

```julia
using Pkg
pkg"add KiteModels"

```

it will install the old version of KiteModels in the new project, but not the latest version of KiteModels.

Which sequence of commands ensures that I get the latest, released version of KiteModels?

I know I can do:

```julia
add KiteModels#main

```

to get the last, unreleased version. Is there a similar command to get the last released version?

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [August 12, 2024, 9:26pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/2 "2024-08-12T21:26:03Z")

</div>

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](https://pkgdocs.julialang.org/v1/registries/#Registry-flavors).

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 9:34pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/3 "2024-08-12T21:34:26Z")

</div>

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:

```julia
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.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [August 12, 2024, 9:39pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/4 "2024-08-12T21:39:10Z")

</div>

Assuming there’s nothing else in the environment holding it back, I would try

```julia
pkg> update KiteModels

```

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [August 12, 2024, 9:41pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/5 "2024-08-12T21:41:48Z")

</div>

Do you have the env variable [`JULIA_PKG_PRESERVE_TIERED_INSTALLED`](https://docs.julialang.org/en/v1/manual/environment-variables/#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).

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 9:45pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/6 "2024-08-12T21:45:11Z")

</div>

No, the default is `tiered`, and that does NOT install the latest version:

```julia
 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:

```julia
pkg"add --preserve none KiteModels"

```

?

Update: Doesn’t work, installs an old version.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 9:57pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/7 "2024-08-12T21:57:23Z")

</div>

So for now I stick with:

```julia
using Pkg
pkg"add KiteModels"; pkg"up"

```

But it is annoying that Pkg.add has no option to install the latest version.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [August 12, 2024, 10:00pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/8 "2024-08-12T22:00:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 10:04pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/9 "2024-08-12T22:04:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [August 12, 2024, 10:08pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/10 "2024-08-12T22:08:38Z")

</div>

Do you have something in the environment that could clamp version of KiteModels?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 10:10pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/11 "2024-08-12T22:10:05Z")

</div>

No, it is a fresh, empty project. And Pkg.update() works.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [August 12, 2024, 10:12pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/12 "2024-08-12T22:12:11Z")

</div>

That’s what `tiered_installed` does which is not the default. That sounds like a bug then. What version of Julia are you using?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 12, 2024, 10:13pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/13 "2024-08-12T22:13:29Z")

</div>

```julia
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 7840U w/ Radeon 780M Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)

```

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [August 13, 2024, 7:28am UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/14 "2024-08-13T07:28:01Z")

</div>

> [@ufechner7](#):
>
> I think Pkg re-uses packages from other project and doesn’t install and precompiles them again if you start a new project.

I can’t replicate.

```julia
$ 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.

```

Do you have a `startup.jl` file?

Does

```julia
pkg> activate --temp
pkg> add KiteModels@0.6.4

```

work and/or give any interesting output?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [August 13, 2024, 8:41am UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/15 "2024-08-13T08:41:54Z")

</div>

I wrote this test script:

```julia
#!/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?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [August 13, 2024, 8:48am UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/16 "2024-08-13T08:48:59Z")

</div>

> [@ufechner7](#):
>
> 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.

```julia
(@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

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 13, 2024, 10:15am UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/17 "2024-08-13T10:15:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [August 13, 2024, 11:52am UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/18 "2024-08-13T11:52:40Z")

</div>

possibly useful code:

> <https://github.com/JuliaLang/Pkg.jl/issues/3926>
>
> \`Pkg\` has seen amazing improvements in the past few versions, with indicators fo…r packages that are upgradeable, hindered from being upgraded, and so on.
> 
> One feature I'm missing that I've found in other ecosystems is a "search" functionality with some basic information about the packages.
> 
> Personally, I'm most interested in learning about package versions and url, a small blurb/about-me could be useful too (see related discussions below for potential approaches)
> 
> I'm envisioning something along the lines of:
> \`\`\`julia
> 
> pkg\> search Makie
> Package 'Makie' is available from:
> \- "General" registry
> Most recent releases: 0.21.2, 0.21.1, 0.21.0, 0.20.10, 0.20.9
> Repository: https://github.com/MakieOrg/Makie.jl.git
> 
> \[Potentially / easy to support too:\] 
> \- "OtherInstalledRegistry" registry
> \[...\]
> \`\`\`
> 
> Below is a quickly hacked together code for obtaining version history for a given package in the General registry, mostly achieved by poking into \`Pkg\`s existing internals (e.g. \`Pkg.status()\`, \`Pkg.print\_status(...)\`, \`Pkg.Types.Context()\`)
> \`\`\`julia
> import Pkg: Pkg, API, Operations, Registry
> 
> function search(pkgname; min\_version = v"0.0.0", max\_version = nothing)
> registries = Registry.reachable\_registries(); # can loop over this to print info from all installed registries
> reg\_ind = findfirst(r -\> r.name == "General", registries);
> reg = registries\[reg\_ind\];
> pkguuids\_in\_registry = collect(keys(reg.pkgs));
> pkgnames\_in\_registry = \[reg.pkgs\[key\].name for key in pkguuids\_in\_registry\];
> 
> pkgname\_ind = findfirst(==(pkgname), pkgnames\_in\_registry);
> pkguuid = pkguuids\_in\_registry\[pkgname\_ind\]
> 
> reg\_pkg = get(reg, pkguuid, nothing); # Pkg.Registry.PkgEntry
> 
> info = Registry.registry\_info(reg\_pkg);
> reg\_compat\_info = Registry.compat\_info(info);
> versions = keys(reg\_compat\_info);
> versions = Base.filter(v -\> !Registry.isyanked(info, v), collect(versions));
> versions\_sorted = sort(versions, rev=true)
> 
> # filter between min\_version and max\_version
> max\_version = isnothing(max\_version) ? maximum(versions\_sorted; init=v"0") : max\_version
> filter!(v -\> min\_version \<= v \<= max\_version, versions\_sorted) 
> 
> version\_list = versions\_sorted\[1:min(5, length(versions\_sorted))\]
> pkg\_url = info.repo
>     
> # Prints what is shown above
> println("Package '$pkgname' is available from:")
> println("- '$(reg.name)' registry")
> println(" Most recent releases: $(join(version\_list, ", "))")
> println(" Repository: $pkg\_url")
> nothing
> end
> \`\`\`
> 
> Having written the code first, then discovered all the discussion about this already (as one does...), I realize more thinking may be needed to hone down a really great long-term interface. That said, I hope a variant of this suggestion can be a small, but practically achievable step, in this direction.
> 
> \------
> 
> relevant issue(s): #3259, #2613, #1397 (with great discussion)
> Related to (but smaller(?) in scope than): \[discourse#98813\](https://discourse.julialang.org/t/searching-and-clustering-julia-packages-by-name-description-topics-and-readme/98813)
> Tags/metadata aspect also described in: #1967, #1070 (includes similar code to the above)
> Similar goals, but web-based: https://juliapackages.com

but … “use juliahub” I suppose.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 13, 2024, 12:20pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/19 "2024-08-13T12:20:09Z")

</div>

Can I use JuliaHub from the REPL though?

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [August 13, 2024, 12:23pm UTC](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110/20 "2024-08-13T12:23:56Z")

</div>

easier to grep through the packages directory perhaps ? - no, that might not work.

[Next page](https://discourse.julialang.org/t/how-to-install-the-newest-version-of-a-package/118110.md?page=2)
