I thought it sufficed to add your current working directory to LOAD_PATH to use modules from there, but apparently that is not so. Is the only way to get local code (for small scale dev/testing) to use include? I could swear this worked last week…
julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca (2019-01-21 21:24 UTC)
...
julia> LOAD_PATH
4-element Array{String,1}:
"@"
"@v#.#"
"@stdlib"
"/l/tests/julia"
julia> pwd()
"/l/tests/julia"
julia> readdir()
31-element Array{String,1}:
...
"MyMod.jl"
"MyMod.jl~"
...
julia> using MyMod
ERROR: ArgumentError: Package MyMod not found in current path:
- Run `import Pkg; Pkg.add("MyMod")` to install the MyMod package.
Stacktrace:
[1] require(::Module, ::Symbol) at ./loading.jl:823
julia>
That all looks fine to me, and I checked that it works on my machine.
In situations like this, I find it useful to try to isolate the smallest difference between the broken example and a working example. For example, I would sanity check by creating a new, empty folder, creating a trivial file in that folder like:
The issue was that I had an empty Project.toml file lying around in that one directory. I’m only at the stage of playing around with Modules, Packages, Projects and everything, so I’m breaking things.
Would you or anybody know of a good introduction to the above subjects?
I don’t think this particular behaviour is documented yet. If it is, it wasn’t visible enough for me to find it: I as well struggled with this issue a few months ago.
The confusion
In particular, I had to look through Julia’s code to understand that any entry in LOAD_PATH, whose directory contains a Project.toml file, will be treated as a “project environment” only. In other words: having a Project.toml file inhibits Julia from using it as a “package repository”.