[Pkg3] Is there any way to install packages "globally"

I’m not sure how to install some package and make it available globally. I mean, that I understand that inside some folder with some project.tolm only packages registered on that file should be available (in principle. This also could be different, using some mechanism so I could allow somehow some script or the REPL to use globally installed packages). My question is that when I add some package to v0.7 I was thinking that I could use it anywhere. But that doesn’t seem to be the case

(v0.7) pkg> st
Status `~/.julia/environments/v0.7/Project.toml`
 [6e4b80f9] BenchmarkTools v0.3.0
 [7073ff75] IJulia v1.8.0
 [91a5bcdd] Plots v0.17.0

julia> using Plots
ERROR: ArgumentError: Module Pkg not found in current path.
Run `Pkg.add("Pkg")` to install the Pkg package.
...

UPDATE: It seems that the problem is related more with JULIA_LOAD_PATH

That error message is a bit of a catch-22 by the way :slight_smile:

The error message are still from the Pkg2 era where everything that somehow managed to be find through all of the loadpaths are loadable in any package. We need to update it.

The reason for this specific error is the following:

  • Packages in a Pkg3 world need to declare their dependencies (including stdlibs).
  • To try make old packages (without Project files) work in the Pkg3 world we parse them and look for import statements that import stdlibs and add that to their registry dependencies.
  • Pkg is special in the sense that this module existed and was exported in 0.6, there is thus no need to import it. We thus fail to find that Plots uses Pkg and thus not add it to the registry.

A short term fix would probably be to add import Pkg to Plots.jl and register a new version of the package. I could also just make the registry script add Pkg to the dependencies for Plots.

In any case, I don’t think Plots has been updated to work on Julia 0.7, but we can certainly add a import Pkg statement when updating the package to Julia master.