Skip to content

Commit 76eaa4c

Browse files
Fix julia#55850 by using safe_realpath instead of abspath in projname (#4025)
* Update REPLExt.jl * Add test * Update test/repl.jl Co-authored-by: Ian Butterworth <[email protected]> * Update test/repl.jl Co-authored-by: Ian Butterworth <[email protected]> * Fix windows tests --------- Co-authored-by: Ian Butterworth <[email protected]> (cherry picked from commit 2ad377f)
1 parent df38587 commit 76eaa4c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ext/REPLExt/REPLExt.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import .REPL: LineEdit, REPLCompletions, TerminalMenus
77

88
import Pkg
99
import .Pkg: linewrap, pathrepr, compat, can_fancyprint, printpkgstyle, PKGMODE_PROJECT
10-
using .Pkg: Types, Operations, API, Registry, Resolve, REPLMode
10+
using .Pkg: Types, Operations, API, Registry, Resolve, REPLMode, safe_realpath
1111

1212
using .REPLMode: Statement, CommandSpec, Command, prepare_cmd, tokenize, core_parse, SPECS, api_options, parse_option, api_options, is_opt, wrap_option
1313

@@ -47,7 +47,7 @@ function projname(project_file::String)
4747
end
4848
for depot in Base.DEPOT_PATH
4949
envdir = joinpath(depot, "environments")
50-
if startswith(abspath(project_file), abspath(envdir))
50+
if startswith(safe_realpath(project_file), safe_realpath(envdir))
5151
return "@" * name
5252
end
5353
end

test/repl.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,4 +734,14 @@ end
734734
end
735735
end
736736

737+
@testset "JuliaLang/julia #55850" begin
738+
tmp_55850 = mktempdir()
739+
tmp_sym_link = joinpath(tmp_55850, "sym")
740+
symlink(tmp_55850, tmp_sym_link; dir_target=true)
741+
withenv("JULIA_DEPOT_PATH" => tmp_sym_link * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
742+
prompt = readchomp(`$(Base.julia_cmd()[1]) --project=$(dirname(@__DIR__)) --startup-file=no -e "using Pkg, REPL; Pkg.activate(io=devnull); REPLExt = Base.get_extension(Pkg, :REPLExt); print(REPLExt.promptf())"`)
743+
@test prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
744+
end
745+
end
746+
737747
end # module

0 commit comments

Comments
 (0)