Package precompile fail with Distributed

I get a persistent error with the following code:

git_julia_proj_path = "SOME_PATH"

using Distributed   
n_procs = 2
rmprocs(workers())
addprocs(2)

# local first
using Pkg
Pkg.activate(git_julia_proj_path)
Pkg.precompile()
using CSV

# on all workers
@everywhere using Pkg
@everywhere Pkg.activate($git_julia_proj_path) # the dollar sign takes the variable from the local (main) worker

@everywhere using CSV

I am on Windows with Julia v"1.8.1". I run this code on the local machine (there are enough cores that this is worthwhile doing).

I tried a bunch of things:

  • changing the order of local and @everywhere package imports, using REPL to use the package
  • cleaning .julia\compiled\
  • Pkg.update()
  • using packages other than CSV

I managed to get it to work once before it stopped working again…

The error if something like:

From worker 2:      Activating project at `C:\git-repos\uber-road-qual-visual\analysis-town-borders\non-linear-gmm\project_files`
      From worker 3:
      From worker 3:    Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
      From worker 3:    Exception: EXCEPTION_ACCESS_VIOLATION at 0x6544d48d -- _jl_restore_incremental at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:3109
      From worker 3:    in expression starting at C:\Users\Gabriel Kreindler\.julia\packages\CSV\7lFhM\src\CSV.jl:36
      From worker 2:
      From worker 2:    Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
      From worker 3:    _jl_restore_incremental at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:3109
      From worker 3:    ijl_restore_incremental at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:3173
      From worker 2:    Exception: EXCEPTION_ACCESS_VIOLATION at 0x6544d48d -- _jl_restore_incremental at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:3109
      From worker 2:    in expression starting at C:\Users\Gabriel Kreindler\.julia\packages\CSV\7lFhM\src\CSV.jl:36
      From worker 2:    _jl_restore_incremental at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:3109
      From worker 2:    ijl_restore_incremental at /cygdrive/c/buildbot/worker/package_win64/build/src\dump.c:3173
      From worker 3:    _include_from_serialized at .\loading.jl:807
      From worker 3:    _require_search_from_serialized at .\loading.jl:1039
      From worker 2:    _include_from_serialized at .\loading.jl:807
      From worker 3:    _require at .\loading.jl:1315
      From worker 2:    _require_search_from_serialized at .\loading.jl:1039
      From worker 3:    _require_prelocked at .\loading.jl:1200
      From worker 2:    _require at .\loading.jl:1315
      From worker 3:    macro expansion at .\loading.jl:1180 [inlined]
      From worker 3:    macro expansion at .\lock.jl:223 [inlined]
      From worker 3:    require at .\loading.jl:1144
      From worker 2:    _require_prelocked at .\loading.jl:1200
      From worker 3:    jfptr_require_38023.clone_1 at C:\Program Files\Julia-1.8.1\lib\julia\sys.dll (unknown line)
      From worker 2:    macro expansion at .\loading.jl:1180 [inlined]
      From worker 2:    macro expansion at .\lock.jl:223 [inlined]
      From worker 2:    require at .\loading.jl:1144
      From worker 3:    jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1838 [inlined]
      From worker 3:    call_require at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:462 [inlined]
      From worker 3:    eval_import_path at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:499
      From worker 3:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:725
      From worker 3:    jl_eval_module_expr at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:203 [inlined]
      From worker 3:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:709
      From worker 3:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
      From worker 3:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
      From worker 2:    jfptr_require_38023.clone_1 at C:\Program Files\Julia-1.8.1\lib\julia\sys.dll (unknown line)
      From worker 3:    ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
      From worker 3:    ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
      From worker 2:    jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1838 [inlined]
      From worker 2:    call_require at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:462 [inlined]
      From worker 2:    eval_import_path at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:499
      From worker 2:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:725
      From worker 2:    jl_eval_module_expr at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:203 [inlined]
      From worker 2:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:709
      From worker 3:    eval at .\boot.jl:368 [inlined]
      From worker 3:    include_string at .\loading.jl:1428
      From worker 2:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
      From worker 2:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
      From worker 2:    ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
      From worker 2:    ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
      From worker 3:    _include at .\loading.jl:1488
      From worker 2:    eval at .\boot.jl:368 [inlined]
      From worker 2:    include_string at .\loading.jl:1428
      From worker 3:    include at .\Base.jl:419 [inlined]
      From worker 3:    include_package_for_output at .\loading.jl:1554
      From worker 2:    _include at .\loading.jl:1488
      From worker 3:    jfptr_include_package_for_output_35040.clone_1 at C:\Program Files\Julia-1.8.1\lib\julia\sys.dll (unknown line)
      From worker 3:    jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1838 [inlined]
      From worker 3:    do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
      From worker 2:    include at .\Base.jl:419 [inlined]
      From worker 2:    include_package_for_output at .\loading.jl:1554
      From worker 3:    eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
      From worker 3:    eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
      From worker 3:    eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:594
      From worker 3:    jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:750
      From worker 3:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:906
      From worker 3:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
      From worker 3:    ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
      From worker 3:    ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
      From worker 2:    jfptr_include_package_for_output_35040.clone_1 at C:\Program Files\Julia-1.8.1\lib\julia\sys.dll (unknown line)
      From worker 2:    jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1838 [inlined]
      From worker 2:    do_call at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:126
      From worker 2:    eval_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:215
      From worker 2:    eval_stmt_value at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:166 [inlined]
      From worker 2:    eval_body at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:594
      From worker 2:    jl_interpret_toplevel_thunk at /cygdrive/c/buildbot/worker/package_win64/build/src\interpreter.c:750
      From worker 3:    eval at .\boot.jl:368 [inlined]
      From worker 3:    include_string at .\loading.jl:1428
      From worker 2:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:906
      From worker 2:    jl_toplevel_eval_flex at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:850
      From worker 2:    ijl_toplevel_eval at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:915 [inlined]
      From worker 2:    ijl_toplevel_eval_in at /cygdrive/c/buildbot/worker/package_win64/build/src\toplevel.c:965
      From worker 3:    include_string at .\loading.jl:1438
      From worker 2:    eval at .\boot.jl:368 [inlined]
      From worker 2:    include_string at .\loading.jl:1428
      From worker 3:    exec_options at .\client.jl:301
      From worker 2:    include_string at .\loading.jl:1438
      From worker 3:    _start at .\client.jl:522
      From worker 2:    exec_options at .\client.jl:301
      From worker 3:    jfptr__start_40826.clone_1 at C:\Program Files\Julia-1.8.1\lib\julia\sys.dll (unknown line)
      From worker 3:    jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1838 [inlined]
      From worker 3:    true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:575
      From worker 2:    _start at .\client.jl:522
      From worker 3:    jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:719
      From worker 3:    mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:59
      From worker 3:    BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
      From worker 3:    RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
      From worker 3:    Allocations: 195803 (Pool: 195105; Big: 698); GC: 1
      From worker 2:    jfptr__start_40826.clone_1 at C:\Program Files\Julia-1.8.1\lib\julia\sys.dll (unknown line)
      From worker 2:    jl_apply at /cygdrive/c/buildbot/worker/package_win64/build/src\julia.h:1838 [inlined]
      From worker 2:    true_main at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:575
      From worker 2:    jl_repl_entrypoint at /cygdrive/c/buildbot/worker/package_win64/build/src\jlapi.c:719
      From worker 2:    mainCRTStartup at /cygdrive/c/buildbot/worker/package_win64/build/cli\loader_exe.c:59
      From worker 2:    BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
      From worker 2:    RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
      From worker 2:    Allocations: 195806 (Pool: 195107; Big: 699); GC: 1
ERROR: On worker 2:
Failed to precompile CSV [336ed68f-0bac-5ca0-87d4-7b16caf5d00b] to C:\Users\Gabriel Kreindler\.julia\compiled\v1.8\CSV\jl_26E2.tmp.
Stacktrace:
  [1] error
    @ .\error.jl:35
  [2] compilecache
    @ .\loading.jl:1705
  [3] compilecache
    @ .\loading.jl:1649 [inlined]
  [4] _require
    @ .\loading.jl:1337
  [5] _require_prelocked
    @ .\loading.jl:1200
  [6] macro expansion
    @ .\loading.jl:1180 [inlined]
  [7] macro expansion
    @ .\lock.jl:223 [inlined]
  [8] require
    @ .\loading.jl:1144
  [9] eval
    @ .\boot.jl:368
 [10] #invokelatest#2
    @ .\essentials.jl:729
 [11] invokelatest
    @ .\essentials.jl:726
 [12] #114
    @ C:\Program Files\Julia-1.8.1\share\julia\stdlib\v1.8\Distributed\src\process_messages.jl:301
 [13] run_work_thunk
    @ C:\Program Files\Julia-1.8.1\share\julia\stdlib\v1.8\Distributed\src\process_messages.jl:70
 [14] run_work_thunk
    @ C:\Program Files\Julia-1.8.1\share\julia\stdlib\v1.8\Distributed\src\process_messages.jl:79
 [15] #100
    @ .\task.jl:484

...and 1 more exception.

Stacktrace:
 [1] sync_end(c::Channel{Any})
   @ Base .\task.jl:436
 [2] macro expansion
   @ .\task.jl:455 [inlined]
 [3] remotecall_eval(m::Module, procs::Vector{Int64}, ex::Expr)
   @ Distributed C:\Program Files\Julia-1.8.1\share\julia\stdlib\v1.8\Distributed\src\macros.jl:219
 [4] top-level scope
   @ C:\Program Files\Julia-1.8.1\share\julia\stdlib\v1.8\Distributed\src\macros.jl:203