Loading a module with Project.toml containing the name field but no uuid

Hello everyone,

I’m on a constant quest to find the easiest way to load a module without using include.
I discovered recently through the use of the DrWatson.jl package that you can do using MyPkg from its environment even though the package has no uuid defined.

Let’s say we have the following:

# MyPkg/src/MyPkg.jl

module MyPkg

plus_one(x) = x + 1 

end
# MyPkg/Project.toml
name = "MyPkg"

Note the absence of the the uuid field.

In the Pkg repl mode:

(@v1.8) pkg> activate .
(MyPkg) pkg>

In the activated environment I can do now

julia> using MyPkg
julia> MyPkg.plus_one(1.2)
2.2

Even though my Project.toml does not contain any uuid, I can still load MyPkg.
This breaks if MyPkg.jl is not placed in the src folder.

This brings me to the following questions:

  1. How is this possible? I could not find any explanation of this behaviour in the docs. Could someone point me to the relevant part of the documentation?

  2. I had to create the Project.toml file manually in order to not get the uuid. Is there a way to generate such a project.toml file containing only a name field for the project and nothing else using the Pkg api?

Thanks in advance

Olivier

I think it gets assigned a “dummy UUID” based on the project path:

Oh yes indeed! I was missing the dummy uuid.

I think this is the relevant piece of documentation:

If X/Project.toml exists and but does not have a top-level UUID entry, uuid is a dummy UUID generated by hashing the canonical (real) path to X/Project.toml.

Thanks a lot!