How to activate the current project with Distributed

If your source file is src/dist.jl, then within it @__DIR__ == "/path/to/project/src". So you have to go up one directory to retrieve the top-level project directory:

@everywhere begin
    import Pkg
    Pkg.activate(joinpath(@__DIR__, ".."))
end

If your julia depot is on a shared filesystem, I would also recommend to take the appropriate steps for the project to be compiled on one node beforehand, so that when starting the distributed computations everything is already done. Last time I checked, problems could arise if several processes attempted to precompile the same set of packages at the same time.

1 Like