Skip to content

Commit

Permalink
Fix julia#55850 by using safe_realpath instead of abspath in projname (
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd authored Oct 4, 2024
1 parent 0ad8abe commit 82dc94e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/REPLMode/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import REPL: TerminalMenus

import ..casesensitive_isdir, ..OFFLINE_MODE, ..linewrap, ..pathrepr
using ..Types, ..Operations, ..API, ..Registry, ..Resolve
import ..stdout_f, ..stderr_f
import ..stdout_f, ..stderr_f, ..safe_realpath

const TEST_MODE = Ref{Bool}(false)
const PRINTED_REPL_WARNING = Ref{Bool}(false)
Expand Down Expand Up @@ -497,7 +497,7 @@ function projname(project_file::String)
end
for depot in Base.DEPOT_PATH
envdir = joinpath(depot, "environments")
if startswith(abspath(project_file), abspath(envdir))
if startswith(safe_realpath(project_file), safe_realpath(envdir))
return "@" * name
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -726,4 +726,15 @@ end
end
end

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

end # module

0 comments on commit 82dc94e

Please sign in to comment.