diff --git a/base/initdefs.jl b/base/initdefs.jl index 0846a47534886..d93590af4d63c 100644 --- a/base/initdefs.jl +++ b/base/initdefs.jl @@ -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 diff --git a/src/init.c b/src/init.c index b293ab1a44b88..64a82792b685f 100644 --- a/src/init.c +++ b/src/init.c @@ -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) { diff --git a/test/loading.jl b/test/loading.jl index 289c25e582b0a..259f55a87c999 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -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)