Skip to content

Commit

Permalink
Absolutify project path specified with --project and JULIA_PROJECT. (#…
Browse files Browse the repository at this point in the history
…28625)

(cherry picked from commit eb8a933)
  • Loading branch information
fredrikekre authored and KristofferC committed Sep 8, 2018
1 parent 79e2e87 commit 0c51ed2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/initdefs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ function init_load_path()
unsafe_string(Base.JLOptions().project) :
get(ENV, "JULIA_PROJECT", nothing))
HOME_PROJECT[] =
project == nothing ? nothing :
project == "" ? nothing :
project == "@." ? current_project() : project
project == "@." ? current_project() : abspath(project)
append!(empty!(LOAD_PATH), paths)
end

Expand Down
2 changes: 2 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
jl_options.outputbc = abspath(jl_options.outputbc, 0);
if (jl_options.machine_file)
jl_options.machine_file = abspath(jl_options.machine_file, 0);
if (jl_options.project && strncmp(jl_options.project, "@.", strlen(jl_options.project)) != 0)
jl_options.project = abspath(jl_options.project, 0);

const char **cmdp = jl_options.cmds;
if (cmdp) {
Expand Down
16 changes: 16 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,22 @@ finally
popfirst!(LOAD_PATH)
end

@testset "--project and JULIA_PROJECT paths should be absolutified" begin
mktempdir() do dir; cd(dir) do
mkdir("foo")
script = """
using Test
old = Base.active_project()
cd("foo")
@test Base.active_project() == old
"""
@test success(`$(Base.julia_cmd()) --project=foo -e $(script)`)
withenv("JULIA_PROJECT" => "foo") do
@test success(`$(Base.julia_cmd()) -e $(script)`)
end
end; end
end

## cleanup after tests ##

for env in keys(envs)
Expand Down

0 comments on commit 0c51ed2

Please sign in to comment.