From d534b58f8325962fbb6d337f7519f35008c222e4 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:14:15 -0300 Subject: [PATCH 1/5] Update REPLExt.jl --- ext/REPLExt/REPLExt.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/REPLExt/REPLExt.jl b/ext/REPLExt/REPLExt.jl index f221d61ac3..d821355045 100644 --- a/ext/REPLExt/REPLExt.jl +++ b/ext/REPLExt/REPLExt.jl @@ -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 @@ -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 From d15bf5699d9a13b66d51da927cf63bbbfc33c3fb Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:58:18 -0300 Subject: [PATCH 2/5] Add test --- test/repl.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/repl.jl b/test/repl.jl index 6b4b32fef8..e3b7ca4d1b 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -733,4 +733,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, "JULIA_LOAD_PATH" => nothing) do + prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using Pkg: Pkg, Types; import REPL; const REPLExt = Base.get_extension(Pkg, :REPLExt); print(REPLExt.projname(Types.find_project_file()))"`) + @test prompt == "@v$(VERSION.major).$(VERSION.minor)" + end +end + end # module From d3e999c5eb8252dfbac900a7b2f533e4f5ecce03 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:42:54 -0300 Subject: [PATCH 3/5] Update test/repl.jl Co-authored-by: Ian Butterworth --- test/repl.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repl.jl b/test/repl.jl index e3b7ca4d1b..e6b5ef4f14 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -737,7 +737,7 @@ end 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, "JULIA_LOAD_PATH" => nothing) do + withenv("JULIA_DEPOT_PATH" => tmp_sym_link * ":", "JULIA_LOAD_PATH" => nothing) do prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using Pkg: Pkg, Types; import REPL; const REPLExt = Base.get_extension(Pkg, :REPLExt); print(REPLExt.projname(Types.find_project_file()))"`) @test prompt == "@v$(VERSION.major).$(VERSION.minor)" end From 13945d0717c69b8398510b9530589c58092296ff Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:02:58 -0300 Subject: [PATCH 4/5] Update test/repl.jl Co-authored-by: Ian Butterworth --- test/repl.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/repl.jl b/test/repl.jl index e6b5ef4f14..22612e3678 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -738,8 +738,8 @@ end tmp_sym_link = joinpath(tmp_55850, "sym") symlink(tmp_55850, tmp_sym_link; dir_target=true) withenv("JULIA_DEPOT_PATH" => tmp_sym_link * ":", "JULIA_LOAD_PATH" => nothing) do - prompt = readchomp(`$(Base.julia_cmd()[1]) --startup-file=no -e "using Pkg: Pkg, Types; import REPL; const REPLExt = Base.get_extension(Pkg, :REPLExt); print(REPLExt.projname(Types.find_project_file()))"`) - @test prompt == "@v$(VERSION.major).$(VERSION.minor)" + 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 From a4929833515aac069d021f22391e374a1fb90879 Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:45:00 -0300 Subject: [PATCH 5/5] Fix windows tests --- test/repl.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repl.jl b/test/repl.jl index 22612e3678..8a44661485 100644 --- a/test/repl.jl +++ b/test/repl.jl @@ -737,7 +737,7 @@ end 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 * ":", "JULIA_LOAD_PATH" => nothing) do + 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