Reputation: 1371
I am trying to load custom modules in julia, but I always get the following error:
ERROR: foo not found
in require at loading.jl:47
where foo is a the following module:
module foo
bar() = "foo"
export bar
end
which is located at "/home/.../julia/modules/" and I also added:
push!(LOAD_PATH, "/home/.../julia/modules/")
to my ~/.juliarc.jl file. What am I missing? Btw, I also reinstalled julia v0.3.10, no effect.
One more thing, if I include the file, I can use the module:
> include("../modules/test.jl")
> using foo
> bar()
> "bar"
works. But it should not necessary, right?
Upvotes: 3
Views: 242
Reputation: 8566
naming the file as the module is a convention in Julia, especially when using using
and import
without including corresponding module definition file.
take a look at the definition of the function require
which is implicitly called by using
to load packages in the loading.jl below.
...
...
function find_in_path(name::AbstractString, wd = pwd())
isabspath(name) && return name
base = name
if endswith(name,".jl")
base = name[1:end-3]
else
name = string(base,".jl")
end
...
...
if you run using foo
, julia will look for foo.jl
in the LOAD_PATH
.
Upvotes: 3