-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
joinpath gives surprising (wrong?) results for unc network paths in Windows #33455
Comments
I'm not in a position to build from source, but I pulled the latest from the nightlies (https://julialang.org/downloads/nightlies.html) page and got the same result:
|
This is just a bug in |
I'm fine with rewriting joinpath(p1, p2, rest...) = joinpath(joinpath(p1, p2), rest...) Which is currently how it's defined and therefore guaranteed to be true. If that's not the case, that's quite concerning and I'd like to understand why. |
It seems that UNC paths are always absolute, so consider the 2-arg version,
The only choices for the last case seem to be:
Neither one is a great option. In any case, I don't see how this is incompatible with the recursive identity since:
|
I'm not disputing that there's a bug here since the BAD results are clearly wrong, but I want to get to the bottom of this claim that the correct behavior of |
If that's the case we default There's a really subtle bug here related to the behavior of const path_separator = "\\"
const path_separator_re = r"[/\\]+"
function pathsep(paths::AbstractString...)
for path in paths
m = match(path_separator_re, String(path))
m !== nothing && return m.match[1:1]
end
return path_separator
end
function _joinpath(a::String, b::String)
isabspath(b) && return b
A, a = splitdrive(a)
B, b = splitdrive(b)
!isempty(B) && A != B && return string(B,b)
C = isempty(B) ? A : B
isempty(a) ? string(C,pathsep(a,b),b) :
occursin(path_separator_re, a[end:end]) ? string(C,a,b) :
string(C,a,pathsep(a,b),b)
end This code is identical to the julia> _joinpath("\\\\server\\share","b")
"\\\\server\\share\\b"
julia> joinpath("\\\\server\\share","b")
"\\\\server\\shareb" For some reason I suspect something related to compiler is going on here. Because if I then use So in fact, |
fixed by #33477 |
I ran my little test on the latest nightly and it look good. Thanks!
|
Using joinpath on a UNC path does not always behave as expected (or as I expect).
In the following example:
joinpath
should be able to join all the parts of a UNC path even if the first part is not the full server+share part. I can certainly see how it would be useful to have it behave that way.Code:
Result:
The text was updated successfully, but these errors were encountered: