Skip to content

Commit 82dc94e

Browse files
Fix julia#55850 by using safe_realpath instead of abspath in projname (#4025) (#4027)
1 parent 0ad8abe commit 82dc94e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/REPLMode/REPLMode.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import REPL: TerminalMenus
1010

1111
import ..casesensitive_isdir, ..OFFLINE_MODE, ..linewrap, ..pathrepr
1212
using ..Types, ..Operations, ..API, ..Registry, ..Resolve
13-
import ..stdout_f, ..stderr_f
13+
import ..stdout_f, ..stderr_f, ..safe_realpath
1414

1515
const TEST_MODE = Ref{Bool}(false)
1616
const PRINTED_REPL_WARNING = Ref{Bool}(false)
@@ -497,7 +497,7 @@ function projname(project_file::String)
497497
end
498498
for depot in Base.DEPOT_PATH
499499
envdir = joinpath(depot, "environments")
500-
if startswith(abspath(project_file), abspath(envdir))
500+
if startswith(safe_realpath(project_file), safe_realpath(envdir))
501501
return "@" * name
502502
end
503503
end

test/repl.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,4 +726,15 @@ end
726726
end
727727
end
728728

729+
@testset "JuliaLang/julia #55850" begin
730+
tmp_55850 = mktempdir()
731+
tmp_sym_link = joinpath(tmp_55850, "sym")
732+
symlink(tmp_55850, tmp_sym_link; dir_target=true)
733+
# DEPOT_PATH must stay only the temp directory otherwise the bug is hidden
734+
withenv("JULIA_DEPOT_PATH" => tmp_sym_link, "JULIA_LOAD_PATH" => nothing) do
735+
prompt = readchomp(`$(Base.julia_cmd()[1]) --project=$(dirname(@__DIR__)) --startup-file=no -e "using Pkg: Pkg, REPLMode; Pkg.activate(io=devnull); print(REPLMode.promptf())"`)
736+
@test prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
737+
end
738+
end
739+
729740
end # module

0 commit comments

Comments
 (0)