Skip to content

Commit bc75cd1

Browse files
christiangnrdKristofferC
authored andcommitted
[REPL] Fix #55850 by using safe_realpath instead of abspath in projname (#55851)
(cherry picked from commit fb77d60)
1 parent 76967d4 commit bc75cd1

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
@@ -79,7 +79,7 @@ function projname(project_file::String)
7979
end
8080
for depot in Base.DEPOT_PATH
8181
envdir = joinpath(depot, "environments")
82-
if startswith(abspath(project_file), abspath(envdir))
82+
if startswith(safe_realpath(project_file), safe_realpath(envdir))
8383
return "@" * name
8484
end
8585
end

stdlib/REPL/test/repl.jl

+10-1
Original file line numberDiff line numberDiff line change
@@ -1781,11 +1781,20 @@ end
17811781

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

1789+
# Issue 55850
1790+
tmp_55850 = mktempdir()
1791+
tmp_sym_link = joinpath(tmp_55850, "sym")
1792+
symlink(tmp_55850, tmp_sym_link; dir_target=true)
1793+
withenv("JULIA_DEPOT_PATH" => tmp_sym_link * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
1794+
prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using REPL; print(REPL.projname(REPL.find_project_file()))"`)
1795+
@test prompt == "@v$(VERSION.major).$(VERSION.minor)"
1796+
end
1797+
17891798
get_prompt(proj::String) = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no $(proj) -e "using REPL; print(REPL.Pkg_promptf())"`)
17901799

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

0 commit comments

Comments
 (0)