Import the same package after activating new environment

The version of the package is determined at the time of Pkg.add. import or using just gets its version from Manifest.toml.

In your case, in the REPL you will get 0.6.2 – which is really saying: in the v1.4.2 environment (or whatever your version is), this is what you will get.

In the other environment, Manifest.toml points to 0.7.4, so that’s what you will get. Except that you are actually in a stacked environment (where the dependencies of v1.4.2 and other are both available. My understanding is that the most recently activated environment wins in this case (so you should get 0.7.4). See

https://docs.julialang.org/en/v1/manual/code-loading/#Environment-stacks-1

and

But if you start Julia, issue using CSV, then activate other and try using CSV again, you are stuck with the version that’s already loaded.

pkg> st shows the package versions resolved in the current environment.

The reason why you could load Primes is likely a stacked environment as well. If it isn’t in the Manifest.toml for a package you activate in this session, you cannot load it.

As for upgrading: you don’t upgrade what’s in the depot. You upgrade what is in the current environment’s Manifest.toml. So, pkg> up CSV in other changes the version in other but nowhere else.

3 Likes