Skip to content
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

Cloning from GitHub over ssh in 0.6-dev #20695

Closed
krcools opened this issue Feb 20, 2017 · 8 comments
Closed

Cloning from GitHub over ssh in 0.6-dev #20695

krcools opened this issue Feb 20, 2017 · 8 comments

Comments

@krcools
Copy link

krcools commented Feb 20, 2017

I get the following error when trying to clone an unregistered package:

julia> Pkg.clone("[email protected]:krcools/CollisionDetection.git")
ERROR: ArgumentError: drive mismatch: METADATA [email protected]:krcools/CollisionDetection.git
Stacktrace:
 [1] joinpath(::String, ::String) at .\path.jl:197
 [2] clone(::String) at .\pkg\entry.jl:210
 [3] (::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}})() at .\pkg\dir.jl:31
 [4] cd(::Base.Pkg.Dir.##2#3{Array{Any,1},Base.Pkg.Entry.#clone,Tuple{String}}, ::String) at .\file.jl:58
 [5] #cd#1(::Array{Any,1}, ::Function, ::Function, ::String, ::Vararg{Any,N} where N) at .\pkg\dir.jl:31
 [6] clone(::String) at .\pkg\pkg.jl:154

julia> versioninfo()
Julia Version 0.6.0-dev.2635
Commit dc2459d* (2017-02-13 07:46 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E3-1505M v5 @ 2.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

julia> Pkg.clone("https://github.com/krcools/CollisionDetection.git")
INFO: Cloning CollisionDetection from https://github.com/krcools/CollisionDetection.git
INFO: Computing changes...
INFO: No packages to install, update or remove

As you can see, cloning works over https but not over ssh. Somehow the ssh url (which contains a colon and thus can be mistaken for a drive/path pair) ends up in joinpath, with an ArgumentError thrown as result.

@StefanKarpinski
Copy link
Member

StefanKarpinski commented Feb 20, 2017

Here's a potential fix:

diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl
index 0d53268f96..84f128d268 100644
--- a/base/pkg/entry.jl
+++ b/base/pkg/entry.jl
@@ -207,16 +207,18 @@ function clone(url::AbstractString, pkg::AbstractString)
 end

 function clone(url_or_pkg::AbstractString)
+    if !(':' in url_or_pkg)
         urlpath = joinpath("METADATA",url_or_pkg,"url")
-    if !(':' in url_or_pkg) && isfile(urlpath)
+        if isfile(urlpath)
             pkg = url_or_pkg
             url = readchomp(urlpath)
             # TODO: Cache.prefetch(pkg,url)
-    else
+            return clone(url,pkg)
+        end
+    end
     url = url_or_pkg
     m = match(r"(?:^|[/\\])(\w+?)(?:\.jl)?(?:\.git)?$", url)
     m !== nothing || throw(PkgError("can't determine package name from URL: $url"))
     pkg = m.captures[1]
-    end
-    clone(url,pkg)
+    return clone(url,pkg)
 end

However, the root cause here is that joinpath can throw an error in the first place. Perhaps that behavior should be reconsidered since joinpath is used all over the place and I don't think people generally expect that it can throw an error – it's essentially just a string manipulation function that happens to interpret strings as if they were file paths. It is, however, pretty unclear what to do when both paths are relative and they have different drives.

@tkelman
Copy link
Contributor

tkelman commented Mar 6, 2017

did #20735 change this at all?

@BoundaryValueProblems
Copy link

I got exactly the same problem with julia v0.5.1 on Windows machines (Windows 10). Interestingly, on Mac OS X and Linux machines, I don't have this issue. Also, on Windows, using Pkg.clone("https://...") works, but not Pkg.clone("git@..."). How can we solve this problem?

@StefanKarpinski
Copy link
Member

See my PR which fixes it. Needs a test, which is a pain since it's a package operation.

@BoundaryValueProblems
Copy link

BoundaryValueProblems commented Mar 11, 2017

@StefanKarpinski, thanks for your PR fix: 8fb132f . I think I modified base/pkg/entry.jl correctly. Yet, I still got the following error:

julia> Pkg.clone("[email protected]:BoundaryValueProblems/MTSG.jl.git")
ArgumentError: drive mismatch: METADATA [email protected]:BoundaryValueProblems/MTSG.jl.git
 in clone at base\pkg.jl:151
 in #cd#1 at base\pkg\dir.jl:31
 in cd at base\file.jl:48
 in #2 at base\pkg\dir.jl:31
 in clone at base\pkg\entry.jl:210
 in joinpath at base\path.jl:82

@StefanKarpinski
Copy link
Member

Did you also recompile Julia after patching the file? That appears to be the same issue.

@BoundaryValueProblems
Copy link

@StefanKarpinski, thanks. But could you tell me how to recompile julia after this patch? I know how to do precompile individual files of mine via precompile, but have never tried to recompile the whole julia.

@StefanKarpinski
Copy link
Member

Don't worry about it, I'm working on adding tests to that PR at which point we can merge it and backport it.

StefanKarpinski added a commit that referenced this issue Mar 13, 2017
work-around joinpath error when cloning git ssh urls (fix #20695)
tkelman pushed a commit that referenced this issue May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants