If I add processes after importing a local package, things work as expected:
julia> using Pkg
julia> Pkg.activate(".")
Activating environment at `~/MyPackage/Project.toml`
julia> using Distributed
julia>
julia> using MyPackage # must import MyPackage first
julia> addprocs(1)
1-element Vector{Int64}:
2
If I import after adding processes, then I get an unexpected error:
julia> using Pkg
julia> Pkg.activate(".")
Activating environment at `~/MyPackage/Project.toml`
julia> using Distributed
julia>
julia> addprocs(1)
julia> using MyPackage
**ERROR:** On worker 2:
ArgumentError: Package QuantumCircuits [01625e0c-f410-4aff-9d33-8c5e8b164a60] is required but does not seem to be installed:
- Run `Pkg.instantiate()` to install all recorded dependencies.
Why is worker 2 throwing an error? I haven’t imported MyPackage on worker 2. I’d expect to be able to activate the project environment before trying to import on the worker.
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Apple M1
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, westmere)