Don't let Pkg downgrade packages automatically

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

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

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, 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 that you don’t want to be downgraded, and (c) install Polynomials again.

2 Likes

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).

1 Like

Cf

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

2 Likes

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.

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

2 Likes

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

pkg> add --preserve=all Example

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

4 Likes

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

6 Likes

Perfect! (But not yet in 1.4.2)

Not anymore, rather.
] preview was removed in 14f5298.

2 Likes

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

The reasoning is discussed in the PR (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.

5 Likes