# Joinpath fails on splitdrive output

**URL:** <https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328>\
**Category:** General Usage\
**Created:** [February 28, 2023, 12:11pm UTC](https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328 "2023-02-28T12:11:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [February 28, 2023, 12:11pm UTC](https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328/1 "2023-02-28T12:11:56Z")

</div>

I would have expected ` joinpath(splitdrive(pwd())) == pwd()`. On Julia 1.8.5

```julia
julia> pwd()
"C:\\Users\\mzaffalon"

julia> joinpath(splitdrive(pwd()))
"\\Users\\mzaffalon"

julia> joinpath(splitpath(pwd())) == pwd()
true

```

I am not sure if this is fixed by [Revise Windows implementation of splitdrive by GunnarFarneback · Pull Request #42204 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/42204)

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 28, 2023, 1:13pm UTC](https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328/2 "2023-02-28T13:13:12Z")

</div>

Not sure what the reasoning for above behaviour is, if there is any, but there is also `splitpath` available which behaves as you expect it.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 28, 2023, 1:20pm UTC](https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328/3 "2023-02-28T13:20:11Z")

</div>

There is some text in the docstring of joinpath which I do not fully understand but seems to be related:

```julia
help?> joinpath
search: joinpath

  joinpath(parts::AbstractString...) -> String
  joinpath(parts::Vector{AbstractString}) -> String
  joinpath(parts::Tuple{AbstractString}) -> String

  Join path components into a full path. If some argument is an absolute path or (on Windows) has a drive
  specification that doesn't match the drive computed for the join of the preceding paths, then prior components are
  dropped.

  Note on Windows since there is a current directory for each drive, joinpath("c:", "foo") represents a path relative
  to the current directory on drive "c:" so this is equal to "c:foo", not "c:\foo". Furthermore, joinpath treats this
  as a non-absolute path and ignores the drive letter casing, hence joinpath("C:\A","c:b") = "C:\A\b".

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> joinpath("/home/myuser", "example.jl")
  "/home/myuser/example.jl"

  julia> joinpath(["/home/myuser", "example.jl"])
  "/home/myuser/example.jl"

```

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [February 28, 2023, 1:32pm UTC](https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328/4 "2023-02-28T13:32:36Z")

</div>

Thanks for your help. It is related to my previous question [Splitpath on UNC shares](https://discourse.julialang.org/t/splitpath-on-unc-shares/95015/1) where `joinpath(splitdrive)` also fails:

```julia
julia> splitdrive("\\\\svfae01-solid01\\SED\\SE")
("\\\\svfae01-solid01\\SED", "\\SE")

julia> joinpath(splitdrive("\\\\svfae01-solid01\\SED\\SE"))
"\\SE"

```

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [February 28, 2023, 1:46pm UTC](https://discourse.julialang.org/t/joinpath-fails-on-splitdrive-output/95328/5 "2023-02-28T13:46:44Z")

</div>

> [@mzaffalon](#):
>
> I am not sure if this is fixed by [Revise Windows implementation of splitdrive by GunnarFarneback · Pull Request #42204 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/42204)

If someone wants to drive that PR forward, feel free to take over. I do want to see that fixed but I don’t use Windows myself, so it’s always low on my priority list and I can’t easily test anything.
