Skip to content

Wrong default REPL prompt when JULIA_DEPOT_PATH is a symlink #55850

@christiangnrd

Description

@christiangnrd

Found when trying to run tests on master but this happens all the way back to at least 1.5.

Discovered because of new tests.

Test Failed at /Users/christian/.julia/juliaup/julia-nightly/share/julia/stdlib/v1.12/REPL/test/repl.jl:1971
  Expression: prompt == "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
   Evaluated: "(v1.12) pkg> " == "(@v1.12) pkg> "

Seems like projname(project_file::String) only checks abspath instead of safe_realpath when comparing envdir and project_file

for depot in Base.DEPOT_PATH
envdir = joinpath(depot, "environments")
if startswith(abspath(project_file), abspath(envdir))
return "@" * name
end
end

Repl walkthrough of my investigation:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.12.0-DEV.1238 (2024-09-23)
 _/ |\__'_|_|_|\__'_|  |  Commit 0fade450a18 (0 days old master)
|__/                   |

julia> withenv("JULIA_DEPOT_PATH" => mktempdir(), "JULIA_LOAD_PATH" => nothing) do
              run(`$(Base.julia_cmd()[1]) --startup-file=no`)
          end
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.12.0-DEV.1238 (2024-09-23)
 _/ |\__'_|_|_|\__'_|  |  Commit 0fade450a18 (0 days old master)
|__/                   |

julia> using REPL; REPL.Pkg_promptf()
[ Info: Precompiling REPL [3fa0cd96-eef1-5676-8a61-b3b8758bbffb] 
"(v1.12) pkg> "

julia> depot = Base.DEPOT_PATH |> first
"/var/folders/4g/lnkpkf3s4rxd_wbl8vwnqs4r0000gn/T/jl_KEaptd"

julia> envdir = joinpath(depot, "environments")
"/var/folders/4g/lnkpkf3s4rxd_wbl8vwnqs4r0000gn/T/jl_KEaptd/environments"

julia> project_file = REPL.find_project_file()
"/private/var/folders/4g/lnkpkf3s4rxd_wbl8vwnqs4r0000gn/T/jl_KEaptd/environments/v1.12/Project.toml"

julia> startswith(abspath(project_file), abspath(envdir)) # Line 91 in Pkg_beforeload.jl
false

Metadata

Metadata

Assignees

No one assigned

    Labels

    REPLJulia's REPL (Read Eval Print Loop)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions