Why does a user have to run Pkg.init() on the first run?

Newbie question here, but on the first run of Pkg.add on a fresh install of julia, the system errors out with a message that a user needs to run Pkg.init()

ERROR: Package metadata directory julia/PKG/v0.6/METADATA doesn’t exist; run Pkg.init() to initialize it.

It seems to know that it is missing and needs to be run. Why doesn’t the system just run it? Is there some risk for the system to run that automatically in this case?

on what platform? it works for me. i am thinking it might be a bug?

one possibility is that you installed Julia pro but try to run it on VSCode? So Julia pro by default install the packages to a different folder.

just maybe. i dont have a pc atm so speculating

I remember seeing that too (both mac and linux) and I thought that’s by design…

Since you can redefine JULIA_PKGDIR, the package manager cannot be sure that you have an ininitialized repo directory, instead of an initialized one full of packages somewhere else that you just forgot to mention.

Pkg3 initializes by default on the first action.

1 Like