Question about setting up new package environment

I am trying to understand how I can efficiently setup a new package environment. I have the following questions,

  1. When I create a new environment using pkg> activate EnvName - why the folder named EnvName with associated Manifest and Project toml files are not created right away? What do I need to do to have the folder automatically created and populated?

  2. I am trying to understand the documentation about --shared switch of pkg.activate function. From the documentation, When the option --shared is given, path will be assumed to be a directory name and searched for in the environments folders of the depots in the depot stack.

  • Isn’t path is always a directory name? (I am assuming all pkg environment is a dedicated folder with some setting in toml file).
  • What does it mean by ā€˜depots in the depot stack’?

Can anybody explain what --shared switch does some other way?

Thanks!

  1. When I create a new environment using pkg> activate EnvName - why the folder named EnvName with associated Manifest and Project toml files are not created right away? What do I need to do to have the folder automatically created and populated?

I’m not sure why they are not created straight away, but they will be created when you add a package to the environment (Pkg.add or Pkg.develop). I’m guessing because there is no information to save until a package is actually added, nothing is created.

  1. I am trying to understand the documentation about --shared switch of pkg.activate function. From the documentation, When the option --shared is given, path will be assumed to be a directory name and searched for in the environments folders of the depots in the depot stack.

The --shared switch looks for/creates environments in a common location, regardless of the working folder. Unless you’ve changed the depot location, this will typically be at ~/.julia/enviroments. You can change that location by modifying the depot location.

For example:

(@v1.6) pkg> activate --shared MyEnv
  Activating new environment at `~/.julia/environments/MyEnv/Project.toml`
(@MyEnv) pkg> 

If I didn’t use the --shared flag, it would just make the environment in my current working folder. The @ symbol infront of the environment name indicates that it’s a shared env.

  • Isn’t path is always a directory name? (I am assuming all pkg environment is a dedicated folder with some setting in toml file).

When not using a shared environment, path can actually be a directory, e.g.

(MyEnv) pkg> activate MyFolder1/MyFolder2/MyEnv
  Activating new environment at `~/MyFolder1/MyFolder2/MyEnv/Project.toml`

This directory can be relative to current working directory, or absolute.

Note if I try to use a path with a shared environment it fails:

(MyEnv) pkg> activate --shared MyFolder1/MyFolder2/MyEnv
ERROR: not a valid name for a shared environment: MyFolder1/MyFolder2/MyEnv

This is why the docs say ā€œpath will be assumed to be a directory nameā€.

  • What does it mean by ā€˜depots in the depot stack’?

The depot stack can be viewed by looking at the DEPOT_PATH variable in Julia. The depots in the depot stack are where the package manager, as well as Julia’s code loading mechanisms, look for package registries, installed packages, named environments, repo clones, cached compiled package images, configuration files, and the default location of the REPL’s history file (from the docs)

For me (Mac user), DEPOT_PATH looks like:

julia> DEPOT_PATH
3-element Vector{String}:
 "/Users/username/.julia"
 "/Applications/Julia-1.6.app/Contents/Resources/julia/local/share/julia"
 "/Applications/Julia-1.6.app/Contents/Resources/julia/share/julia"

It can be seen that the first depot in the path is where my shared environment was created above. If I wanted the depot to be elsewhere I could modify this variable by pushing in a new folder.

2 Likes