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
…#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)
  • Loading branch information
christiangnrd authored and IanButterworth committed Oct 5, 2024
1 parent df38587 commit 76eaa4c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ext/REPLExt/REPLExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import .REPL: LineEdit, REPLCompletions, TerminalMenus

import Pkg
import .Pkg: linewrap, pathrepr, compat, can_fancyprint, printpkgstyle, PKGMODE_PROJECT
using .Pkg: Types, Operations, API, Registry, Resolve, REPLMode
using .Pkg: Types, Operations, API, Registry, Resolve, REPLMode, safe_realpath

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

Expand Down Expand Up @@ -47,7 +47,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
10 changes: 10 additions & 0 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -734,4 +734,14 @@ 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)
withenv("JULIA_DEPOT_PATH" => tmp_sym_link * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do
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())"`)
@test prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
end
end

end # module

0 comments on commit 76eaa4c

Please sign in to comment.