# Don't let Pkg downgrade packages automatically

**URL:** https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424
**Category:** Internals & Design
**Created:** [July 21, 2020, 10:10am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424 "2020-07-21T10:10:46Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)
#### Post date: [July 21, 2020, 10:10am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/1 "2020-07-21T10:10:46Z")

</div>

I just installed Polynomials, which downgraded a bunch of my packages, and broke a lot of stuff.

```julia
ERROR: LoadError: LoadError: UndefVarError: tostr_sizehint not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at ./Base.jl:26
 [2] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
 [3] include(::Module, ::String) at ./Base.jl:377
 [4] include(::String) at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:1
 [5] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
ERROR: LoadError: Failed to precompile CategoricalArrays [324d7699-5711-5eae-9e2f-1d82baa6b597] to /Users/evar/.julia/compiled/v1.4/CategoricalArrays/RHXoP_KRChu.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/DataFrames/0Em9Q/src/DataFrames.jl:11
ERROR: LoadError: Failed to precompile DataFrames [a93c6f00-e57d-5684-b7b6-d8193f3e46c0] to /Users/evar/.julia/compiled/v1.4/DataFrames/AR9oZ_KRChu.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/RData/6wYre/src/RData.jl:3
ERROR: LoadError: Failed to precompile RData [df47a6cb-8c03-5eed-afd8-b6050d6c41da] to /Users/evar/.julia/compiled/v1.4/RData/idMMA_KRChu.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/RDatasets/1Ih8s/src/RDatasets.jl:2
ERROR: LoadError: LoadError: UndefVarError: tostr_sizehint not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at ./Base.jl:26
 [2] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
 [3] include(::Module, ::String) at ./Base.jl:377
 [4] include(::String) at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:1
 [5] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
ERROR: LoadError: Failed to precompile CategoricalArrays [324d7699-5711-5eae-9e2f-1d82baa6b597] to /Users/evar/.julia/compiled/v1.4/CategoricalArrays/RHXoP_KRChu.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/Gadfly/cqMtH/src/Gadfly.jl:9
ERROR: LoadError: LoadError: UndefVarError: tostr_sizehint not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at ./Base.jl:26
 [2] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
 [3] include(::Module, ::String) at ./Base.jl:377
 [4] include(::String) at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:1
 [5] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
ERROR: LoadError: Failed to precompile CategoricalArrays [324d7699-5711-5eae-9e2f-1d82baa6b597] to /Users/evar/.julia/compiled/v1.4/CategoricalArrays/RHXoP_KRChu.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/DataFrames/0Em9Q/src/DataFrames.jl:11
ERROR: LoadError: LoadError: UndefVarError: tostr_sizehint not defined
Stacktrace:
 [1] getproperty(::Module, ::Symbol) at ./Base.jl:26
 [2] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
 [3] include(::Module, ::String) at ./Base.jl:377
 [4] include(::String) at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:1
 [5] top-level scope at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/deprecated.jl:101
in expression starting at /Users/evar/.julia/packages/CategoricalArrays/qcwgl/src/CategoricalArrays.jl:39
ERROR: LoadError: Failed to precompile CategoricalArrays [324d7699-5711-5eae-9e2f-1d82baa6b597] to /Users/evar/.julia/compiled/v1.4/CategoricalArrays/RHXoP_KRChu.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
 [3] _require(::Base.PkgId) at ./loading.jl:1029
 [4] require(::Base.PkgId) at ./loading.jl:927
 [5] require(::Module, ::Symbol) at ./loading.jl:922
 [6] include(::Module, ::String) at ./Base.jl:377
 [7] top-level scope at none:2
 [8] eval at ./boot.jl:331 [inlined]
 [9] eval(::Expr) at ./client.jl:449
 [10] top-level scope at ./none:3
in expression starting at /Users/evar/.julia/packages/FreqTables/NHPMj/src/FreqTables.jl:2

```

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 21, 2020, 10:24am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/2 "2020-07-21T10:24:43Z")

</div>

Is the broken stuff meant to use the Polynomials package, or did you install Polynomials for a different project?

If it’s for a different project, you can [create its own environment](https://julialang.github.io/Pkg.jl/v1/environments/), to avoid that kind of conflicts with package versions.

If it’s for the same project, a solution is: (a) uninstall Polynomials; (b) [pin the packages](https://julialang.github.io/Pkg.jl/v1/managing-packages/#Pinning-a-package-1) that you don’t want to be downgraded, and (c) install Polynomials again.

---

<div class="post-metadata">

### Author: ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)
#### Post date: [July 21, 2020, 10:37am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/3 "2020-07-21T10:37:38Z")

</div>

I installed Polynomials just to try it out, so my problem was solved by uninstalling it and updating everything to their latest versions. But I don’t think it’s nice to downgrade my packages without a warning (and my explicit confirmation).  
I don’t know exactly what it broke, these errors I pasted are from importing Polynomials itself. But installing any other packages also produced similar errors before I uninstalled Polynomials (so basically Julia was completely broken).

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 21, 2020, 10:58am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/4 "2020-07-21T10:58:40Z")

</div>

Cf

[https://github.com/JuliaLang/Pkg.jl/issues/1927](https://github.com/JuliaLang/Pkg.jl/issues/1927)

[https://github.com/JuliaLang/Pkg.jl/issues/1675](https://github.com/JuliaLang/Pkg.jl/issues/1675)

This may be an issue with Polynomials.jl too, so investigating and fixing that would be useful.

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 21, 2020, 11:00am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/5 "2020-07-21T11:00:32Z")

</div>

> [@NightMachinary](#):
>
> But I don’t think it’s nice to downgrade my packages without a warning (and my explicit confirmation)

Not only downgrading; upgrading packages may also be very breaking. But since the dependency trees of packages often involve dozens of other packages, any update or new package will most likely change the versions of others. So, in my opinion warnings or confirmation prompts would not be very informative or useful, because you would see them _every time_ you update or add a package.

I’d rather say that you have to assume that `]add`, `]rm` and `]up` can always break your code. So it’s good practice to get accustomed to create a different environment for each new project. (And that also makes your code more stable and reproducible, as indicated in the documentation that I linked in the previous post.)

For trying packages, I have a “sandbox” evironment that does not interfere with “serious work”, and I wipe it out (just deleting the `Project.toml` and `Manifest.toml`) as soon as I have finished my testing.

> [@NightMachinary](#):
>
> so my problem was solved by uninstalling it and updating everything to their latest versions

You might also be interested in `]undo`, as mentioned here:

> [@Pin all packages of a project](https://discourse.julialang.org/t/pin-all-packages-of-a-project/39308/3):
>
> Note that you can always just undo (@v1.4) pkg\> up # oops ... Updating `~/.julia/environments/v1.4/Project.toml` [587475ba] ↑ Flux v0.10.4 #master (https://github.com/FluxML/Flux.jl.git) ⇒ v0.10.5 #master (https://github.com/FluxML/Flux.jl.git) [91a5bcdd] ↑ Plots v1.2.3 ⇒ v1.2.4 [295af30f] ↑ Revise v2.5.4 ⇒ v2.6.6 [e88e6eb3] ↑ Zygote v0.4.19 #master (https://github.com/FluxML/Zygote.jl.git) ⇒ v0.4.20 #master (https://github.com/FluxML/Zygote.jl.git) Updating `~/.julia/environment…

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [July 21, 2020, 11:06am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/6 "2020-07-21T11:06:34Z")

</div>

undo is great, didn’t know it exists!  
Some kind of dry run for Pkg commands would be nice, what-if, or however it can be called.  
I see there is also

```julia
pkg> add --preserve=all Example

```

> all Preserve the state of all existing dependencies (including recursive dependencies)

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 21, 2020, 11:27am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/7 "2020-07-21T11:27:12Z")

</div>

> [@oheil](#):
>
> Some kind of dry run for Pkg commands would be nice

`]preview`: previews a subsequent command without affecting the current state

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [July 21, 2020, 11:31am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/8 "2020-07-21T11:31:16Z")

</div>

Perfect! (But not yet in 1.4.2)

---

<div class="post-metadata">

### Author: ![lbilli](https://avatars.discourse-cdn.com/v4/letter/l/59ef9b/32.png) [@lbilli](https://discourse.julialang.org/u/lbilli)
#### Post date: [July 21, 2020, 11:57am UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/9 "2020-07-21T11:57:27Z")

</div>

Not anymore, rather.  
`] preview` was removed in [14f5298](https://github.com/JuliaLang/Pkg.jl/commit/14f529831bc34bae2816abc0a48ebcbf966fb3ce).

---

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 21, 2020, 12:12pm UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/10 "2020-07-21T12:12:17Z")

</div>

Oh, I had missed that. Why was it removed?

---

<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: [July 21, 2020, 12:16pm UTC](https://discourse.julialang.org/t/dont-let-pkg-downgrade-packages-automatically/43424/11 "2020-07-21T12:16:53Z")

</div>

The reasoning is discussed in [the PR](https://github.com/JuliaLang/Pkg.jl/pull/1367) (which can be hard to find from the commit, but there’s a little link at the top where it says “master (#1367)”). Basically because it requires a lot of code to maintain and `undo` covers the use case in a more flexible way.
