-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Conflicting environments are handled incorrectly #35663
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
Comments
Just to give a third flavor where you get a compat problem without switching project after loading a package: export JULIA_DEPOT_PATH="/tmp/.julia"
julia -q
(v1.4) pkg> add Colors@0.12
...
Updating `/private/tmp/.julia/environments/v1.4/Project.toml`
[5ae59095] + Colors v0.12.0
Updating `/private/tmp/.julia/environments/v1.4/Manifest.toml`
[3da002f7] + ColorTypes v0.10.2
[5ae59095] + Colors v0.12.0
...
(v1.4) pkg> activate CustomProject
Activating new environment at `/private/tmp/envs/CustomProject/Project.toml`
(CustomProject) pkg> add ColorTypes@0.8
...
[3da002f7] + ColorTypes v0.8.1 # Colors is incompatible with this
Updating `/private/tmp/envs/CustomProject/Manifest.toml`
[3da002f7] + ColorTypes v0.8.1
[53c48c17] + FixedPointNumbers v0.7.1
julia> using Colors # this is the first package load
[ Info: Precompiling Colors [5ae59095-9a9b-59fe-a467-6f913c188581]
ERROR: LoadError: UndefVarError: XRGB not defined The reason for the error here is that while |
Note that the behavior in my last comment is explicitly documented https://docs.julialang.org/en/v1/manual/code-loading/#Environment-stacks-1Th but I thought it was worth pointing out anyway since it is related.
|
Interesting. One could modify my suggestion in the OP to warn users about the incompatibility only if a package operation fails. OTOH, this would fail to catch cases where there is no compile-fatal mismatch, only a functionality-correctness-fatal mismatch. I worry the last class of problems is really hard to debug properly. |
I think it would at least make sense to warn when loading a package and that package is already loaded from a different path than where it would be otherwise be loaded from. |
I think that warning upon activating a different environment (i.e. Flavor 1) is the most viable option. I'm don't think that putting a warning in the code loading path when an earlier stack environment shadows the dependency of a package from later in the stack since that is fine 95% of the time and just works. That seems like it's going to be a very common warning that people will just learn to ignore and will become a pointless annoyance that makes Julia look janky—like method ambiguity warnings of old. |
While warning when a dependency is already loaded from somewhere other than where it would be loaded if a later environment was used in isolation would be too fiddly, it might be ok if we recorded compat info in manifests when resolving them and checked if the already-loaded version is within the compat bounds or not. Recording in the manifest is helpful since otherwise you have to look in potentially a lot of random places to figure out what the compat bounds are, whereas you already had to find a dependency in the manifest in order to know what to load, so we're already doing that work mostly. |
How about manually editing |
Code loading needs to be pretty simple: we are already pushing the limits of what it's reasonable to do while loading code. Anything that avoids complicating code loading further is better. |
Isn't it impossible to detect |
This is causing massive problems in ArrayInterface: JuliaArrays/ArrayInterface.jl#206, JuliaArrays/ArrayInterface.jl#207, JuliaArrays/ArrayInterface.jl#208. |
I would say the real flavor 2 is when you load a package from e.g. the default environment but one of the dependencies of that package exists in the currently active environment. Julia will then just load the dependency in the active environment which very well may be incompatible with the package. This is described in https://docs.julialang.org/en/v1/manual/code-loading/#Environment-stacks:
Regarding flavor 1. The way to do this is IMO to recompute the path when we try load an already loaded package and compare that to the path where the package got originally loaded from. If these two differ, then warn. Right now, I think it is a bit too expensive to do that path recomputation every time, but I am working on some code loading caching (in a similar vein to #37906) that would make this cheap enough to be feasible. |
I would add that this is an annoying issue in VSCode, since you always "go through" your principal environment before activating a more specific environment. This means that currently I have to* run everything from the terminal and explicitly specifying * I'm sure I could fix this if I spent enough time trying to update all my packages, but I've already spent 2 days on this and I have no wish to spend more. |
@junglegobs are you starting Julia from a shell within VS Code? If so, then yes you have to do the steps you describe, but that is very much not the recommended way! If you start the Julia REPL via the The short version of this is: if you use Some mod might mark both the original comment and my response here as off-topic, they are probably more of a distraction from the original problem here :) |
@davidanthoff I was technically using the To mods who might deem this off topic, I would say this highlights how confusing this conflicting environments issue can be, since I do not understand what the difference between EDIT: The issue was that I was using the VSCode Julia REPL with a system image, so I had to re-compile this and then it worked. |
373: Use consistent environments r=charleskawczynski a=charleskawczynski See [this issue](JuliaLang/julia#35663). Co-authored-by: Charles Kawczynski <[email protected]>
Any progress on this? This is still causing regular issues for me. I don't understand the details, but in timholy/Revise.jl#727, @timholy suggests this should be fixable now? |
I'm reporting this to julia itself (rather than in Pkg.jl) because key components of the fix seemingly must be made in
base/loading.jl
. No objections, though, if folks want to transfer this to Pkg.jl.This bug comes in two closely-related flavors.
Flavor 1: switching between incompatible environments should be disallowed
Suppose I have two projects with incompatible
[compat]
requirements:Proj1.toml
:Proj2.toml
:Now let's use these in a Julia session:
That error is very confusing for the developer.
XRGB
was defined in ColorTypes v0.10, and I've declared that Colors v0.12 depends on it. So how canXRGB
be undefined? The key information---that I've switched environments---is rarely reported by users. (timholy/Revise.jl#468, JuliaIO/QuartzImageIO.jl#62)To me, it seems that the right way to handle it is to throw
AFAICT, currently we don't save any information about the version of loaded packages. This is why I suspect we need to fix this partially in
base/loading.jl
.Flavor 2: creation of new environments must preserve session compatibility
If you've loaded one version of a package, creation of new environments should probably write compatible version info into the Manifest of a newly-created environment.
It would be a little weird that a new project gets affected by the environment of an unrelated package, but until we can load multiple versions of the same module I don't see a good alternative.
The text was updated successfully, but these errors were encountered: