<p dir="auto">Using joinpath on a UNC path does not always behave as expected (or as I expect).</p>
<p dir="auto">In the following example:</p>
<ul dir="auto">
<li>Case 7 seems like a definite defect.</li>
<li>Cases 5 &amp; 6 may be debatable, but I would also argue that <code class="notranslate">joinpath</code> 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.</li>
</ul>
<p dir="auto">Code:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import InteractiveUtils
InteractiveUtils.versioninfo()

println()
@show &quot;1: &quot; * joinpath(&quot;D:&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;)
@show &quot;2: &quot; * joinpath(&quot;D:\\&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;)
@show &quot;3: &quot; * joinpath(&quot;D:\\a&quot;, &quot;b&quot;, &quot;c&quot;)
@show &quot;4: &quot; * joinpath(&quot;D:\\a\\&quot;, &quot;b&quot;, &quot;c&quot;)

println()
@show &quot;5: &quot; * joinpath(&quot;\\\\server&quot;, &quot;share&quot;, &quot;b&quot;, &quot;BAD&quot;)   # expect &quot;\\\\server\\share\\b\\BAD&quot;
@show &quot;6: &quot; * joinpath(&quot;\\\\server\\&quot;, &quot;share&quot;, &quot;b&quot;, &quot;BAD&quot;) # expect &quot;\\\\server\\share\\b\\BAD&quot;
@show &quot;7: &quot; * joinpath(&quot;\\\\server\\share&quot;, &quot;b&quot;, &quot;BAD&quot;)     # expect &quot;\\\\server\\share\\b\\BAD&quot;
@show &quot;8: &quot; * joinpath(&quot;\\\\server\\share\\&quot;, &quot;b&quot;, &quot;GOOD&quot;)  # expect &quot;\\\\server\\share\\b\\GOOD&quot;"><pre class="notranslate"><span class="pl-k">import</span> InteractiveUtils
InteractiveUtils<span class="pl-k">.</span><span class="pl-c1">versioninfo</span>()

<span class="pl-c1">println</span>()
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>1: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span>D:<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span>)
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>2: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span>D:<span class="pl-cce">\\</span><span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span>)
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>3: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span>D:<span class="pl-cce">\\</span>a<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span>)
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>4: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span>D:<span class="pl-cce">\\</span>a<span class="pl-cce">\\</span><span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span>)

<span class="pl-c1">println</span>()
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>5: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\\\\</span>server<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>share<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>BAD<span class="pl-pds">"</span></span>)   <span class="pl-c"><span class="pl-c">#</span> expect "\\\\server\\share\\b\\BAD"</span>
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>6: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\\\\</span>server<span class="pl-cce">\\</span><span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>share<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>BAD<span class="pl-pds">"</span></span>) <span class="pl-c"><span class="pl-c">#</span> expect "\\\\server\\share\\b\\BAD"</span>
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>7: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\\\\</span>server<span class="pl-cce">\\</span>share<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>BAD<span class="pl-pds">"</span></span>)     <span class="pl-c"><span class="pl-c">#</span> expect "\\\\server\\share\\b\\BAD"</span>
<span class="pl-c1">@show</span> <span class="pl-s"><span class="pl-pds">"</span>8: <span class="pl-pds">"</span></span> <span class="pl-k">*</span> <span class="pl-c1">joinpath</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-cce">\\\\</span>server<span class="pl-cce">\\</span>share<span class="pl-cce">\\</span><span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>GOOD<span class="pl-pds">"</span></span>)  <span class="pl-c"><span class="pl-c">#</span> expect "\\\\server\\share\\b\\GOOD"</span></pre></div>
<p dir="auto">Result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

&quot;1: &quot; * joinpath(&quot;D:&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;) = &quot;1: D:a\\b\\c&quot;
&quot;2: &quot; * joinpath(&quot;D:\\&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;) = &quot;2: D:\\a\\b\\c&quot;
&quot;3: &quot; * joinpath(&quot;D:\\a&quot;, &quot;b&quot;, &quot;c&quot;) = &quot;3: D:\\a\\b\\c&quot;
&quot;4: &quot; * joinpath(&quot;D:\\a\\&quot;, &quot;b&quot;, &quot;c&quot;) = &quot;4: D:\\a\\b\\c&quot;

&quot;5: &quot; * joinpath(&quot;\\\\server&quot;, &quot;share&quot;, &quot;b&quot;, &quot;BAD&quot;) = &quot;5: \\\\server\\sharebBAD&quot;
&quot;6: &quot; * joinpath(&quot;\\\\server\\&quot;, &quot;share&quot;, &quot;b&quot;, &quot;BAD&quot;) = &quot;6: \\\\server\\sharebBAD&quot;
&quot;7: &quot; * joinpath(&quot;\\\\server\\share&quot;, &quot;b&quot;, &quot;BAD&quot;) = &quot;7: \\\\server\\sharebBAD&quot;
&quot;8: &quot; * joinpath(&quot;\\\\server\\share\\&quot;, &quot;b&quot;, &quot;GOOD&quot;) = &quot;8: \\\\server\\share\\b\\GOOD&quot;"><pre class="notranslate"><code class="notranslate">Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

"1: " * joinpath("D:", "a", "b", "c") = "1: D:a\\b\\c"
"2: " * joinpath("D:\\", "a", "b", "c") = "2: D:\\a\\b\\c"
"3: " * joinpath("D:\\a", "b", "c") = "3: D:\\a\\b\\c"
"4: " * joinpath("D:\\a\\", "b", "c") = "4: D:\\a\\b\\c"

"5: " * joinpath("\\\\server", "share", "b", "BAD") = "5: \\\\server\\sharebBAD"
"6: " * joinpath("\\\\server\\", "share", "b", "BAD") = "6: \\\\server\\sharebBAD"
"7: " * joinpath("\\\\server\\share", "b", "BAD") = "7: \\\\server\\sharebBAD"
"8: " * joinpath("\\\\server\\share\\", "b", "GOOD") = "8: \\\\server\\share\\b\\GOOD"
</code></pre></div>
<p dir="auto">See also discussion over at <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="487490757" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/Pkg.jl/issues/1328" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/Pkg.jl/issues/1328/hovercard" href="https://github.com/JuliaLang/Pkg.jl/issues/1328">JuliaLang/Pkg.jl#1328</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="487350321" data-permission-text="Title is private" data-url="https://github.com/JuliaDynamics/DrWatson.jl/issues/82" data-hovercard-type="issue" data-hovercard-url="/JuliaDynamics/DrWatson.jl/issues/82/hovercard" href="https://github.com/JuliaDynamics/DrWatson.jl/issues/82">JuliaDynamics/DrWatson.jl#82</a></p>
<p dir="auto">For network drives <code class="notranslate">realpath</code> returns a wrong path.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; realpath(&quot;Z://&quot;)
&quot;UNC\\Mac\\Home\\&quot;

julia&gt; realpath(&quot;C://&quot;)
&quot;C:\\&quot;"><pre class="notranslate"><code class="notranslate">julia&gt; realpath("Z://")
"UNC\\Mac\\Home\\"

julia&gt; realpath("C://")
"C:\\"
</code></pre></div>
<p dir="auto">Tested on:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)"><pre class="notranslate"><code class="notranslate">Julia Version 1.2.0
Commit c6da87ff4b (2019-08-20 00:03 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
</code></pre></div>
<p dir="auto">It's this call:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" 349 len = ccall(:GetFinalPathNameByHandleW, stdcall, UInt32, (Int, Ptr{UInt16}, UInt32, UInt32),
 350                              h, buf, (oldlen=len)-1, 0x0)"><pre class="notranslate"><code class="notranslate"> 349 len = ccall(:GetFinalPathNameByHandleW, stdcall, UInt32, (Int, Ptr{UInt16}, UInt32, UInt32),
 350                              h, buf, (oldlen=len)-1, 0x0)
</code></pre></div>
<p dir="auto">with <code class="notranslate">buf</code> being</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1|julia&gt; transcode(String,buf)
&quot;\\\\?\\UNC\\Mac\\Home\\\ .... garbage due to length not being corrected&quot;"><pre class="notranslate"><code class="notranslate">1|julia&gt; transcode(String,buf)
"\\\\?\\UNC\\Mac\\Home\\\ .... garbage due to length not being corrected"
</code></pre></div>