1

I found these instructions on importing modules in Julia, but I'm getting a somewhat strange behavior, and I was wondering if this was normal.

My files tst.jl and Tmp.jl are:

tst.jl
    1 include("./Tmp.jl")
    2 import Main.Tmp
    3 
    4 Main.Tmp.greetings()

Tmp.jl
    1 module Tmp
    2     export greetings
    3     function greetings()
    4         println("Greetings Earthlings")
    5     end                                                                              
    6 end

But my tst.jl cannot see Tmp unless its under Main.

My LOAD_PATH also looks kind of strange:

julia> LOAD_PATH
3-element Array{String,1}:
 "@"      
 "@v#.#"  
 "@stdlib"

Is this normal, or could something be wrong with my installation?

I tried using JuliaBox and got

julia> LOAD_PATH
3-element Array{Any,1}:
 "/opt/julia-0.6.2/local/share/julia/site/v0.6"
 "/opt/julia-0.6.2/share/julia/site/v0.6"
 "/home/jrun/.julia/v0.6"

However, thats v0.6, while I am using Julia v1.0.2 on OpenSUSE Tumbleweed.

I downloaded the binaries from https://julialang.org/downloads/ and manually moved libs and all into corresponding root directories.

1 Answer 1

4

But my tst.jl cannot see Tmp unless its under Main.

no, you should use relative module paths, see Relative and absolute module paths

tst.jl
    1 include("./Tmp.jl")
    2 using .Tmp
    3 
    4 greetings()

My LOAD_PATH also looks kind of strange:

don't worry, that's normal in Julia1.0 era. X-ref: https://discourse.julialang.org/t/interpreting-load-path-in-1-0/13529

1
  • Thank you! Much appreciated
    – wamster
    Commented Dec 9, 2018 at 21:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.