How can I add a path to my current path in Julia, so that I can organize files and modules in folders, but still access them?
Note: the following paths may be Unix-specific.
You can add the file .juliarc.jl
to your home directory, and include the line
@everywhere push!(LOAD_PATH,"/path/to/my/code")
The @everywhere
ensures that it will work even if you've started julia with multiple workers.
This is an updated and extended version of the answer by tholy and ederag. On Linux and Windows with Julia 1.0 one can add the folder myproject/src
in the user homefolder to the Julia LOAD_PATH
by adding
using Distributed
@everywhere push!(LOAD_PATH, joinpath(homedir(), "myproject", "src"))
to <homedir>/julia/config/startup.jl
. For a fresh Julia install, startup.jl
nor the folder config
exists (on Linux at least). Just create the file and folder and Julia will read startup.jl
automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With