When I’m not in a Project directory, I can make a file like so:
# M1.jl
module M1
export M1Type
struct M1Type
data::Real
end
end
and then from that directory:
push!(LOAD_PATH, pwd()
and then
using M1
and that all works just fine. But if I’m in a Project directory (I have a Project.toml file), I can’t figure out how to use M1 in a similar way.
julia> using M1
ERROR: ArgumentError: Package M1 not found in current path:
- Run `import Pkg; Pkg.add("M1")` to install the M1 package.
I’ve tried to activate the local project and ]add M1
, ]add ./M1.jl
, ]add /full/path/to/M1.jl
, etc., but I’m reasonably sure that that’s just for packages, not local modules, and it just says:
ERROR: The following package names could not be resolved:
* M1 (not found in project, manifest or registry)
Please specify by known `name=uuid`.
hence I don’t know how to make Julia “know” about my local M1 module when I’m in a Project directory.
(I know I can include("M1.jl")
, but that does something a little different, such that anything that needs M1
needs to know where it’s loaded.)
In How to load a module from the current directory?, the “solution” was to delete the Project.toml file. Not what I’m looking to do!
I feel like I’ve read over the Module and Code Loading sections of the doc a bunch without figuring this out.