Behavior of cd() in Julia script

Hi, I have a Julia script as below:

    generate_default_project("./default1")
    make_julia_model("./default1/Network.vff", "./default2")

    println(pwd())
    cd("./default2/")
    println(pwd())
    println("run the model")
    include("default2/Static.jl") 

The 1st line creates a folder ./default1, and the 2nd line generates some Julia scripts and puts them under folder ./default2.
The output from the 1st println(pwd()) is the absolute path of ./, and the 2nd one is of ./default2.
My question is on the last line. Here Static.jl is a script under ./default2, and the 2nd println(pwd()) indicates that the cwd is ./default2.
But if I tried include("./Static.jl"), it just does not work.
Can anyone explain what is happening here? Thanks much!
I am using Julia1.5 on Ubuntu 18.04.

You may find this discussion helpfull:

In short, quoted from @Tamas_Papp

2 Likes

To elaborate on what @oheil said above, it’s always best to pass to include absolute paths, and also use joinpath to write paths, which takes care of different path separators across different operating systems.

1 Like

Thanks! This is very helpful!

1 Like