Julia 0.4 cannot find modules in local path on Ubuntu

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 I try to load the julia -e "using ModuleName" 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 

Everything works correctly with julia 0.3.11 in the local directory, but with Julia 0.4.0 error this does not work. I am using 64 bit Ubuntu 14.04. How can i fix this?

+6
source share
4 answers

currently (v0.4.0), using does not appear in the current working directory. but the good news is that you can use something like using .ModuleName to load modules into CWD while problem # 4600 (prior to version 5.0) is implemented.

this undocumented change from v0.3 to v0.4 is associated with this commit. if you want using to behave like v0.3. you can change this line to find_in_path(name) and recompile julia from the modified source code.

+5
source

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

 JULIA_LOAD_PATH=. julia 
+3
source

If you are developing some kind of code, this is best for me: create main.jl in the root of your package / module folder. it contains

include("your-source.jl")

and possibly also

include("your-tests.jl")

you can just open the julia session in the console, work on "your-source.jl" and just send this line to the terminal whenever you want to try. Once you're done, you can add the package to the download path.

+2
source

When you call using ModuleName , Julia looks at paths that are already defined in the LOAD_PATH constant.

To check the contents of the LOAD_PATH constant, just name it:

 julia>LOAD_PATH 2-element Array{ByteString,1}: "C:\\Users\\AliReza\\AppData\\Local\\Julia-0.4.0\\local\\share\\julia\\site\\v0 .4" "C:\\Users\\AliReza\\AppData\\Local\\Julia-0.4.0\\share\\julia\\site\\v0.4" 

And what is your current working directory?

 julia> pwd() "C:\\Users\\AliReza\\AppData\\Local\\Julia-0.4.0" 

You can include create a file related to the current location if it exists:

 julia> include("missedModule.jl") ERROR: could not open file C:\Users\AliReza\AppData\Local\Julia-0.4.0\missedModu le.jl in include at boot.jl:261 in include_from_node1 at loading.jl:304 

You will get another error if you want to load a module that does not exist in LOAD_PATH

 julia> using LocalModule ERROR: ArgumentError: LocalModule not found in path in require at loading.jl:233 

If LocalModule.jl is a file in the local working directory and you want to download it using using , click the current path to LOAD_PATH , push!(LOAD_PATH, pwd()) , now you can load LocalModule, using , from the working directory.

+1
source

All Articles