From 6b979b67d433e2cdc5f8d68433cb12d78033835b Mon Sep 17 00:00:00 2001
From: Tony Kelman <tony@kelman.net>
Date: Tue, 10 Nov 2015 07:51:55 -0800
Subject: [PATCH 1/3] put a try around the symlink in mkcachedir

ref issue 12166
---
 base/pkg/cache.jl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/base/pkg/cache.jl b/base/pkg/cache.jl
index f4b33db198326..28cbe03cb2d04 100644
--- a/base/pkg/cache.jl
+++ b/base/pkg/cache.jl
@@ -27,8 +27,10 @@ function mkcachedir()
         if !isdir(rootcache)
             mkdir(rootcache)
         end
-        symlink(rootcache, cache)
-        return
+        try
+            symlink(rootcache, cache)
+            return
+        end
     end
     mkdir(cache)
 end

From 5779ccef2e9acf086ce490b5c200d3c54f690164 Mon Sep 17 00:00:00 2001
From: Tony Kelman <tony@kelman.net>
Date: Tue, 17 Nov 2015 03:59:23 -0800
Subject: [PATCH 2/3] Don't warn about file symlinks when creating a directory
 junction

---
 base/file.jl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/base/file.jl b/base/file.jl
index 312d511cff60a..a5bf43def7cc4 100644
--- a/base/file.jl
+++ b/base/file.jl
@@ -404,7 +404,7 @@ function symlink(p::AbstractString, np::AbstractString)
     flags = 0
     @windows_only if isdir(p); flags |= UV_FS_SYMLINK_JUNCTION; p = abspath(p); end
     err = ccall(:jl_fs_symlink, Int32, (Cstring, Cstring, Cint), p, np, flags)
-    @windows_only if err < 0
+    @windows_only if err < 0 && !isdir(p)
         Base.warn_once("Note: on Windows, creating file symlinks requires Administrator privileges.")
     end
     uv_error("symlink",err)

From bae49b97a8c0417a3d7b225842fd52e0e95def06 Mon Sep 17 00:00:00 2001
From: Tony Kelman <tony@kelman.net>
Date: Tue, 17 Nov 2015 13:16:52 -0800
Subject: [PATCH 3/3] assume Pkg.clone input is a url if it contains :

Assuming we're highly unlikely to allow colons in registered package names

Works around `ERROR: stat: unknown error (UNKNOWN)` when calling stat
on a network-drive path with multiple colons in it
---
 base/pkg/entry.jl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl
index 1f647c6e3e66a..be2c729fd1b2c 100644
--- a/base/pkg/entry.jl
+++ b/base/pkg/entry.jl
@@ -208,7 +208,7 @@ end
 
 function clone(url_or_pkg::AbstractString)
     urlpath = joinpath("METADATA",url_or_pkg,"url")
-    if isfile(urlpath)
+    if !(':' in url_or_pkg) && isfile(urlpath)
         pkg = url_or_pkg
         url = readchomp(urlpath)
         # TODO: Cache.prefetch(pkg,url)