Project precompilation fails with `ArgumentError: Invalid header in cache file ...`

I have a julia project that refuses to ] precompile. I get the following error:

Precompiling project...
  ✗ odecontrol
  296 dependencies successfully precompiled in 290 seconds (8 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

odecontrol [add7d8ba-c849-48e8-ace6-f334edce53fd]

ArgumentError: Invalid header in cache file /home/skainswo/.julia/compiled/v1.6/odecontrol/jl_uXlmeI.
WARNING: --output requested, but no modules defined during run

odecontrol is the name of the top-level project. I completely deleted ~/.julia prior to running this as well.

What could be causing this error? Why is Julia creating a cache file with an invalid header?

2 Likes

If you’re interested in reproducing this error, you can do the following (requires Nix):

  1. Clone GitHub - samuela/research at b2ff21c3e5a098ba4feca38b79879f95b46ffdb3.
  2. cd into julia/odecontrol, and run nix-shell.
  3. rm -rf ~/.julia
  4. julia --project, and then ] precompile
3 Likes

Would it be because odecontrol.jl does not define an actual module ?
I got the same error on one of my files, apparently because of that.

I’d like a better error message in that case, though.

Yes, it turns out that’s correct! I forgot to post an update but the resolution was to add an empty module file: research/odecontrol.jl at master · samuela/research · GitHub

Indeed, as I see from your correction, it has to be a module, so you added an empty module, not just an empty file. (“empty module file” = “(empty module) file” rather than “empty (module file)” :slight_smile: )