diff --git a/base/loading.jl b/base/loading.jl index 2314c530851378..5d1ebaf2112359 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -3122,10 +3122,8 @@ mutable struct CacheHeaderIncludes const modpath::Vector{String} # seemingly not needed in Base, but used by Revise end -function replace_depot_path(path::AbstractString) - @static if Sys.iswindows() - path = replace(path, Filesystem.path_separator_re=>Filesystem.pathsep()) - end +function replace_depot_path(the_path::AbstractString) + path = abspath(the_path) for depot in DEPOT_PATH !isdir(depot) && continue @@ -3133,17 +3131,14 @@ function replace_depot_path(path::AbstractString) if isdirpath(depot) depot = dirname(depot) end - - @static if Sys.iswindows() - depot = replace(depot, Filesystem.path_separator_re=>Filesystem.pathsep()) - end + depot = abspath(depot) if startswith(path, string(depot, Filesystem.pathsep())) || path == depot path = replace(path, depot => "@depot"; count=1) - break + return path end end - return path + return the_path end function restore_depot_path(path::AbstractString, depot::AbstractString) diff --git a/test/relocatedepot.jl b/test/relocatedepot.jl index 8fd3bbb3ce2c31..cb6468e7bd1473 100644 --- a/test/relocatedepot.jl +++ b/test/relocatedepot.jl @@ -70,21 +70,6 @@ if !test_relocated_depot @test Base.replace_depot_path(jlrc) != "@depot-rc2" @test Base.replace_depot_path(jlrc) == jlrc end - if Sys.iswindows() - # windows accepts '\\' and '/' as path separators - mktempdir() do dir - jlrc = string(dir, "/", "julia-rc2") - jl = string(dir, "/", "julia") - mkdir(jl) - push!(DEPOT_PATH, jl) - @test Base.replace_depot_path(jl) == "@depot" - @test Base.replace_depot_path(string(jl,"/")) == string("@depot","\\") - @test Base.replace_depot_path(string(jl,"\\")) == string("@depot","\\") - @test Base.replace_depot_path(jlrc) != "@depot-rc2" - @test Base.replace_depot_path(jlrc) == - replace(jlrc, Base.Filesystem.path_separator_re=>"\\") - end - end end end