Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent people from loading incompatible packages via changing enviroments between loads #36372

Open
oxinabox opened this issue Jun 20, 2020 · 5 comments
Labels
packages Package management and loading

Comments

@oxinabox
Copy link
Contributor

I think many people have known this is possible for a while.
Because compatibility is checked at package install time on a per enviroment basis.
And because modules are not reloaded (ever), including after changing enviroments.

Today I think I saw this in the wild.

Here is a way to reproduce what i saw posted in Slack:

# julia --startup-file=no

# make for fresh enviroments
rm("a"; recursive=true, force=true); rm("b", recursive=true; force=true);
mkdir("a"); mkdir("b");

using Pkg

Pkg.activate("a")
pkg"add CodeTracking@1"
using CodeTracking  # Load CodeTracking@1

Pkg.activate("b")
pkg"add Revise@2.7.2"
using Revise  # Load Revise, which would load CodeTracking@5.9 but doesn't because CodeTracking@1 is already loaded

# We have now put Revise in an invalid state because 
# Revise@2.7.2 is compatible only with CodeTracking@5.9, 
# and errors if it is used with CodeTracking@1

# Demonstrate the error:
pkg"add Example"
using Example
pkg"dev --local Example"

Revise will then flip-out because the API of CodeTracking is not what it said it was compatible with.

(b) pkg> Revise.LogRecord(Error, evaluation error starting at /Users/oxinabox/.julia/packages/Example/aqsx3/src/Example.jl:4, lowered
, Revise_e943ed8b, "/Users/oxinabox/.julia/packages/Revise/tV8FE/src/lowered.jl", 106, (mod=Example, ex=begin
    #= /Users/oxinabox/.julia/packages/Example/aqsx3/src/Example.jl:4 =#
    hello(who::String) = begin
            #= /Users/oxinabox/.julia/packages/Example/aqsx3/src/Example.jl:9 =#
            "Hello, $(who)"
        end
end)MethodError: Cannot `convert` an object of type Tuple{LineNumberNode,Expr} to an object of type Array{Tuple{LineNumberNode,Expr},
1}
  ...
Stacktrace:
 [1] convert(::Type{Union{Missing, Array{Tuple{LineNumberNode,Expr},1}}}, ::Tuple{LineNumberNode,Expr}) at ./missing.jl:69
 [2] setindex!(::IdDict{Type,Union{Missing, Array{Tuple{LineNumberNode,Expr},1}}}, ::Any, ::Any) at ./abstractdict.jl:585
 [3] add_signature!(::Revise.CodeTrackingMethodInfo, ::Any, ::LineNumberNode) at /Users/oxinabox/.julia/packages/Revise/tV8FE/src/Rev
ise.jl:489)Revise.LogRecord(Error, evaluation error starting at /Users/oxinabox/.julia/packages/Example/aqsx3/src/Example.jl:11, lowe
red, Revise_e943ed8b, "/Users/oxinabox/.julia/packages/Revise/tV8FE/src/lowered.jl", 106, (mod=Example, ex=begin
    #= /Users/oxinabox/.julia/packages/Example/aqsx3/src/Example.jl:11 =#
    domath(x::Number) = begin
            #= /Users/oxinabox/.julia/packages/Example/aqsx3/src/Example.jl:16 =#
            x + 5
        end
@mbauman mbauman added the packages Package management and loading label Jun 23, 2020
@oxinabox
Copy link
Contributor Author

oxinabox commented Sep 7, 2020

cf #37421 (comment)

@timholy
Copy link
Member

timholy commented Sep 8, 2020

Also xref #35663

@oxinabox
Copy link
Contributor Author

oxinabox commented Jun 9, 2022

I think when activating environments we should first check all loaded packages and if they are not compatible with the environment we should error.

I think in 1.9 that is finally relatively easy as we record the versions of packages when we load them.

@KristofferC
Copy link
Member

Alternatively, something like #44329.

@oxinabox
Copy link
Contributor Author

@timholy is this just plain a duplicate of #35663 ?
So we can close this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Package management and loading
Projects
None yet
Development

No branches or pull requests

4 participants