How to register a local Julia package in a local registry?

I assume that this is for personal use and you are not a system administrator for a large group.

Maintaining a registry is hard work. I would avoid creating a registry if at all possible. If your goal is to make the use of scripts less painful, a lighter solution exists: shared environments.

A shared environment is a regular environment, created in a canonical location. This means that Pkg will be able to locate it by name: you do not have to specify an explicit path.

To set up a shared environment:

  • give it a name: Pkg.activate("ScriptEnvironment"; shared=true)
  • populate it: Pkg.add(Pkg.PackageSpec(; path="/path/to/Foo")) (depending on your use case, you can also use Pkg.develop, add registered packages, etc)
  • that's all!

Now all your scripts can use the shared environment:

using Pkg
Pkg.activate("ScriptEnvironment"; shared=true)
using Foo

If other sets of scripts require different sets of packages, repeat the procedure with a different shared name. Pkg environments are really cheap so feel free to make liberal use of this approach.


Note: I would discourage beginning scripts with Pkg.add("Foo") because this carries the risk of inadvertently polluting the active environment.


There are some instructions on registry creation and maintenance at https://github.com/HolyLab/HolyLabRegistry.

Tags:

Package

Julia