Interactive browser-based authentication to private Julia Pkg servers.
Step 1: Make sure that PkgAuthentication.jl is installed in the default global Julia package environment (v1.x
)
julia> delete!(ENV, "JULIA_PKG_SERVER");
julia> import Pkg
julia> Pkg.activate("v$(VERSION.major).$(VERSION.minor)"; shared = true)
julia> Pkg.add("PkgAuthentication")
One easy way to set the JULIA_PKG_SERVER
environment variable is to add the following
line to your startup.jl
file:
ENV["JULIA_PKG_SERVER"] = "my-pkg-server.example.com"
Step 3: Put the following snippet into your startup.jl
file
# create a new anonymous module for the init code to not pollute the global namespace
Base.eval(Module(), quote
import PkgAuthentication
PkgAuthentication.install();
end)
With the above snippet, Pkg will automatically prompt you when you need to authenticate.
However, if you want to authenticate immediately (instead of waiting until the first Pkg operation that needs authentication), you can do so as follows. First, make sure that you have completed steps 1, 2, and 3 above. Then, open the Julia REPL and run the following:
julia> import PkgAuthentication
julia> PkgAuthentication.authenticate();
If you are using this private Pkg server for the first time, you probably want to make sure that you add any private registries that might be served by this Pkg server.
First, make sure that you have completed steps 1, 2, and 3 above. Then, open the Julia REPL and run the following:
julia> import Pkg
julia> Pkg.Registry.add()
julia> Pkg.Registry.update()
For implementation details, please see docs/internals.md
.