Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The command to add to path in Julia language

Tags:

path

julia

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?

like image 652
user25004 Avatar asked May 12 '15 17:05

user25004


2 Answers

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.

like image 120
tholy Avatar answered Sep 26 '22 07:09

tholy


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.

like image 33
RikH Avatar answered Sep 26 '22 07:09

RikH