There are other questions related to this issue on SO but I think I tried the recommended solution without success though.
So, in the spirit of my baby-steps towards learning Julia, I tried to create a module locally. The folder structure of my module is as follows:
- TrimmedGrassmanAvwerage/
- src/
- TrimmedGrassmanAverage.jl
- Utils/
- dummy.jl
The contents of dummy.jl
are simply:
function dummy(x)
x + oneunit(x)
end
Similarly, the contents of TrimmedGrassmanAverage
are:
module TrimmedGrassmanAverage
export Utils,
dummy
include("Utils/dummy.jl")
end
Now, in my REPL I do the following:
julia> include("TrimmedGrassmanAverage/src/TrimmedGrassmanAverage.jl")
This returns:
Main.TrimmedGrassmanAverage
Now I do:
using TrimmedGrassmanAverage
This returns the error:
ERROR: ArgumentError: Package TrimmedGrassmanAverage not found in current path:
- Run `Pkg.add("TrimmedGrassmanAverage")` to install the TrimmedGrassmanAverage package.
I thought that doing the `include("...") will put the package in the path and julia should be able to find it. However, clearly there is some more steps missing.
EDIT
However, I can do:
using Main.TrimmedGrassmanAverage
and then I can call:
TrimmedGrassmanAverage.dummy(10);
I am not sure why the Main
namespace has to be added and also why I cannot just call dummy
without the Trimmed...
since I export the dummy
function.