Skip to content

Commit

Permalink
JULIA_DEPOT_PATH: expand empty path to default
Browse files Browse the repository at this point in the history
This makes the behavior for JULIA_DEPOT_PATH expansion match that
of JULIA_LOAD_PATH expansion and allows one to manipulate the path
uncondionally with shell expressions like this:

    export JULIA_DEPOT_PATH="$JULIA_DEPOT_PATH:/system/depot"

It also changes JULIA_LOAD_PATH expansion to do user name expansion
just like JULIA_DEPOT_PATH does, bringing the two variables into
closer behavioral agreement.
  • Loading branch information
StefanKarpinski committed Feb 8, 2019
1 parent ea24d37 commit 0abc65a
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,30 @@ isinteractive() = (is_interactive::Bool)

const DEPOT_PATH = String[]

function append_default_depot_path!(DEPOT_PATH)
path = joinpath(homedir(), ".julia")
path in DEPOT_PATH || push!(DEPOT_PATH, path)
path = abspath(Sys.BINDIR, "..", "local", "share", "julia")
path in DEPOT_PATH || push!(DEPOT_PATH, path)
path = abspath(Sys.BINDIR, "..", "share", "julia")
path in DEPOT_PATH || push!(DEPOT_PATH, path)
end

function init_depot_path()
empty!(DEPOT_PATH)
if haskey(ENV, "JULIA_DEPOT_PATH")
depots = split(ENV["JULIA_DEPOT_PATH"], Sys.iswindows() ? ';' : ':')
append!(empty!(DEPOT_PATH), map(expanduser, depots))
str = ENV["JULIA_DEPOT_PATH"]
isempty(str) && return
for path in split(str, Sys.iswindows() ? ';' : ':')
if isempty(path)
append_default_depot_path!(DEPOT_PATH)
else
path = expanduser(path)
path in DEPOT_PATH || push!(DEPOT_PATH, path)
end
end
else
push!(empty!(DEPOT_PATH), joinpath(homedir(), ".julia"))
push!(DEPOT_PATH, abspath(Sys.BINDIR, "..", "local", "share", "julia"))
push!(DEPOT_PATH, abspath(Sys.BINDIR, "..", "share", "julia"))
append_default_depot_path!(DEPOT_PATH)
end
end

Expand Down Expand Up @@ -148,6 +164,7 @@ function parse_load_path(str::String)
env = current_project()
env === nothing && continue
end
env = expanduser(env)
env in envs || push!(envs, env)
end
end
Expand Down

0 comments on commit 0abc65a

Please sign in to comment.