Creating Packages tutorial: Precompile error

I am trying to make a new package, using Julia v1.10 on macosx. Coming back to basics and following the tutorial ( 5. Creating Packages · Pkg.jl ), I am running into a precompilation error. (This happens for all external dependencies, whether using using or import).

Steps I followed:

  1. Open new julia session, go to package mode with ] and then:
    generate HelloWorld
  2. Exit, move to new HelloWorld directory, then ] and
    activate .
    add Random, JSON
  3. Edit src/HelloWorld.jl to add lines:
    import Random
    import JSON
  4. Try import HelloWorld or ] instantiate produces the error:
PkgPrecompileError: The following 1 direct dependency failed to precompile:

HelloWorld 

Failed to precompile HelloWorld [a7910909-222d-43b5-af01-f98d6d1097cc] to "/Users/me/.julia/compiled/v1.10/HelloWorld/jl_8N6nzx".
ERROR: LoadError: ArgumentError: Package JSON [682c06a0-de6a-54ab-a142-c8b1cf79cde6] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

Stacktrace:
  [1] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1996
  [2] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1882
  [3] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
  [4] invoke_in_world
    @ ./essentials.jl:923 [inlined]
  [5] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1873
  [6] macro expansion
    @ ./loading.jl:1860 [inlined]
  [7] macro expansion
    @ ./lock.jl:267 [inlined]
  [8] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1823
  [9] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [10] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [11] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1816
 [12] include
    @ ./Base.jl:495 [inlined]
 [13] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2292
 [14] top-level scope
    @ stdin:4
in expression starting at .../HelloWorld/src/HelloWorld.jl:1
in expression starting at stdin:

Am I doing something stupid?
Note: my standard environment is clean (nothing added to v1.10)

I found what the problem was: I was trying to develop the package in a folder that was on my JULIA_LOAD_PATH. After removing that folder for the path, everything worked fine.

I am not sure why this happens and if this is intentional. Eventually I will have to put the folder back on the Julia load path, if I want to use it (as a locally stored package). Or is it made so that packages can only be updated locally using dev?

Yes, you don’t need packages to be in JULIA_LOAD_PATH to use them. You can use dev in the pkg repl with the path to the local package to add that package to an environment.

Messing with JULIA_LOAD_PATH is discouraged by now, now it’s dev in Revise-d development and add from registries otherwise (registries provide the information needed for versioned dependency resolution), though activating a package’s environment directly is enough for precompilation, import, and less convenient development. But I am curious why JULIA_LOAD_PATH causes this failure.