Packages in default project

Viewed 34

I'm new to Julia.

Situation) I made a (local project, e.g., by Pkg.activate(".") and use a package which is installed in default project but not in the local one, i.e., using package_installed_only_in_the_default_one. So I was confused.

Question) Are the packages in the default project shared and can be used in other projects?

1 Answers

The short answer to your question is yes, if you use a default value of LOAD_PATH variable.

Here is a more detailed explanation.

What you ask for is managed by the LOAD_PATH variable which specifies what using and import statements consider as project environments or package directories when loading code.

As you can read in the Julia manual entry on Environment stacks you have the following rules:

There are a couple of noteworthy features of this design:

  1. The primary environment—i.e. the first environment in a stack—is faithfully embedded in a stacked environment. The full dependency graph of the first environment in a stack is guaranteed to be included intact in the stacked environment including the same versions of all dependencies.
  2. Packages in non-primary environments can end up using incompatible versions of their dependencies even if their own environments are entirely compatible. This can happen when one of their dependencies is shadowed by a version in an earlier environment in the stack (either by graph or path, or both).

Now by default LOAD_PATH has value ["@", "@v#.#", "@stdlib"] which means that:

  1. @ refers to the "current active environment" (this is the primary environment mentioned above that you have activated)
  2. @v#.# refers to the appropriate environment in ~/.julia/environments/ folder. The # characters, are replaced with the major and minor components of the Julia version number.
  3. @stdlib expands to the absolute path of the current Julia installation's standard library directory.
Related