Skip to content

Commit fb77d60

Browse files
[REPL] Fix #55850 by using safe_realpath instead of abspath in projname (#55851)
1 parent 3a132cf commit fb77d60

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

stdlib/REPL/src/Pkg_beforeload.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function projname(project_file::String)
8888
end
8989
for depot in Base.DEPOT_PATH
9090
envdir = joinpath(depot, "environments")
91-
if startswith(abspath(project_file), abspath(envdir))
91+
if startswith(safe_realpath(project_file), safe_realpath(envdir))
9292
return "@" * name
9393
end
9494
end

stdlib/REPL/test/repl.jl

+10-1
Original file line numberDiff line numberDiff line change
@@ -1966,11 +1966,20 @@ end
19661966

19671967
@testset "Dummy Pkg prompt" begin
19681968
# do this in an empty depot to test default for new users
1969-
withenv("JULIA_DEPOT_PATH" => mktempdir(), "JULIA_LOAD_PATH" => nothing) do
1969+
withenv("JULIA_DEPOT_PATH" => mktempdir() * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
19701970
prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using REPL; print(REPL.Pkg_promptf())"`)
19711971
@test prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
19721972
end
19731973

1974+
# Issue 55850
1975+
tmp_55850 = mktempdir()
1976+
tmp_sym_link = joinpath(tmp_55850, "sym")
1977+
symlink(tmp_55850, tmp_sym_link; dir_target=true)
1978+
withenv("JULIA_DEPOT_PATH" => tmp_sym_link * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
1979+
prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using REPL; print(REPL.projname(REPL.find_project_file()))"`)
1980+
@test prompt == "@v$(VERSION.major).$(VERSION.minor)"
1981+
end
1982+
19741983
get_prompt(proj::String) = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no $(proj) -e "using REPL; print(REPL.Pkg_promptf())"`)
19751984

19761985
@test get_prompt("--project=$(pkgdir(REPL))") == "(REPL) pkg> "

0 commit comments

Comments
 (0)