Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia 0.4 cannot found modules in local path on Ubuntu

Tags:

ubuntu

julia

I have a file called ModuleName.jl in a local directory. I believe this file contains a valid module:

#!/usr/bin/env julia
module ModuleName
...
end

When trying to load the module julia -e "using ModuleName" I get:

ERROR: ArgumentError: ModuleName not found in path
in require at ./loading.jl:233
in process_options at ./client.jl:284
in _start at ./client.jl:411

All works right with julia 0.3.11 in the local directory, but it fails with Julia 0.4.0. I use 64bit Ubuntu 14.04. How can I fix this?

like image 646
hombit Avatar asked Oct 12 '15 17:10

hombit


3 Answers

currently(v0.4.0), using doesn't look in the current working directory. but the good news is you can use something like using .ModuleName to load modules in CWD as long as issue #4600 is implemented(before v0.5.0).

this undocumented change from v0.3 to v0.4 is due to this commit. if you want to make using behave as it in v0.3. you can change this line to find_in_path(name) and recompile julia from the modified source code.

like image 79
Gnimuc Avatar answered Nov 04 '22 10:11

Gnimuc


In addition to the other suggestions, I have had success by setting the environment variable for the Julia load path (JULIA_LOAD_PATH) to include the local directory. In other words, running Julia with:

JULIA_LOAD_PATH=. julia
like image 3
Daniel Arndt Avatar answered Nov 04 '22 10:11

Daniel Arndt


If you are developign some code, this works best for me: create a main.jl at the root of your package/module folder. it contains

include("your-source.jl")

and maybe also

include("your-tests.jl")

you can then just open a julia session in your console, work on "your-source.jl", and just send this line into the terminal whenever you want to try it out. Once you are done you can add the package onto the load path.

like image 3
Florian Oswald Avatar answered Nov 04 '22 09:11

Florian Oswald