How Julia's virtual environment physically store the packages added in the environment?

Hi,
I am trying to understand the environment in Julia which can be initiated in ] Pkg mode with activate . But when I add a new package with a specific version with add where it physically installed? For example in Python if I create an environment with conda conda create -n newenv python==3.7 the it create an environment in ..../miniconda3/envs/ and all the environments are there so If I add any package it will be installed in ..../miniconda3/envs/newenv/site-packages/ physically. But in case of Julia where the Packages installed physically or how to access them?

All the packages are physically downloaded in the .julia/packages folder, regardless of the environment you added them in.

When you activate . you tell julia to create a new environment in the current folder (pwd()) by creating a Project.toml and Manifest.toml file an save them in the same current folder. This file contains a list of the packages you added in this new environment, but physically they all reside in .julia/packages (even if you added multiple versions of the same package in different environments).

More info here:
https://julialang.github.io/Pkg.jl/v1/getting-started/

8 Likes

Additionally you can use pathof to find exactly where a module has been loaded from.

5 Likes

That Fantastic, just tried it with help: pathof(m::Module) any one in future will bump here can use pathof with module name pathof(ProjectFlow) to see the path.

Note that in most cases, you don’t need to know the path of the files that make up a package. The idea is that the package manager and code loading will take of this for you.

3 Likes

if you want to access them directly, odds are that you should not be using ] add
but rather ] dev, and for my perference i suggest ] dev --local which will put them relative to your current Project.toml in dev/<pkgname>.

Though if you just want to look at the source,
I suggest: using @less or @edit (but don’t change anything) in the REPL.
Or usine methods(...) then typing the number of the one you want to look at and pressing ctrl+q.
(or the same in response to a stack trace.)
Or using Cthulu.jl

4 Likes