Add package on remote worker

I am trying to install packages on a Distributed worker, but get errors during precompilation that don’t occur when running the same commands on the server manually.

using Distributed
pids = addprocs(["server.edu"])
remotecall_wait(pids[1]) do
    @eval using Pkg
    Pkg.activate("/tmp/temp_project")
    Pkg.instantiate()
    Pkg.add("CUDA") 
end        
...From worker 2:      5 dependencies errored....

More generally, how can I use Distributed without (1) having a shared filesystem or (2) manually setting up project environments on all servers over SSH in some external script?

DistributedEnvironments.jl was put together for helping with this. It takes a look at the currently active local environment and reproduces that on each machine you give it and sets them up as workers.