I am working on a project that I’ve put into a module. The working directory of this module is in my Base.load_path()
and running using thvaccine
works as expected. I can be in the v1.0
environment and still using thvaccine
works.
However, when I try to execute on multiple workers (on local machine), it gives me an error.
julia> @everywhere using thvaccine
ERROR: On worker 2:
ArgumentError: Package thvaccine not found in current path:
- Run `import Pkg; Pkg.add("thvaccine")` to install the thvaccine package.
This is surprising to me since the path is available via Base.load_path()
and that the main Julia process has no issues in locating the package. Anyways, the solution to this problem can be found here. Particularly, running
addprocs(4; exeflags="--project")
@everywhere using thvaccine
works perfectly. As far as I know the --project
flags is essentially running ] activate .
But I am very confused here about how environment works. I thought environments really only matter for the Project.toml
and Manifest.toml
files. Infact, when I launch a fresh Julia and run using thvaccine
in the v1.0 env (since the path is in Base.load_path()
), everything works fine.
I rarely ever even type ] activate .
except when I want to add a dependency to my project or run unit tests though ]
.
So why is it that my workers need to be started with the project? How does “activating the environment” have anything to do with parallel workers. I feel like I have less ideal understanding of environments.