JuliaLang / Pkg.jl

Pkg - Package manager for the Julia programming language
https://pkgdocs.julialang.org
Other
614 stars 253 forks source link

Add package with specific branch failing since julia 1.5.2 #2230

Open imikim opened 3 years ago

imikim commented 3 years ago

Since julia 1.5.2, adding a package with a specific branch fails:

(@v1.5) pkg> add https://username@bitbucket.org/orgname/reponame.git#dev

In julia 1.5.1, it works fine. (It is a private repo, if that matters). Without specifying the branch, it works fine on any version (1.5.1, 1.5.2, 1.5.3)

The versions stated are julia versions and the Pkg used is the bundled one.

The error in julia 1.5.2 and 1.5.3 is:

ERROR: ArgumentError: invalid version range: "bitbucket.org/orgname/reponame.git"
Stacktrace:
 [1] Pkg.Types.VersionRange(::String) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/versions.jl:136
 [2] Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Rev, Pkg.REPLMode.Subdir}(::String) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/argument_parsers.jl:66
 [3] iterate at ./generator.jl:47 [inlined]
 [4] collect_to!(::Array{String,1}, ::Base.Generator{Array{String,1},Type{Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Rev, Pkg.REPLMode.Subdir}}}, ::Int64, ::Int64) at ./array.jl:732
 [5] collect_to_with_first!(::Array{String,1}, ::String, ::Base.Generator{Array{String,1},Type{Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Rev, Pkg.REPLMode.Subdir}}}, ::Int64) at ./array.jl:710
 [6] _collect(::Array{String,1}, ::Base.Generator{Array{String,1},Type{Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Rev, Pkg.REPLMode.Subdir}}}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at ./array.jl:704
 [7] collect_similar at ./array.jl:628 [inlined]
 [8] map at ./abstractarray.jl:2162 [inlined]
 [9] parse_package(::Array{Pkg.REPLMode.QString,1}, ::Dict{Symbol,Any}; add_or_dev::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/argument_parsers.jl:10
 [10] (::Pkg.REPLMode.var"#64#69")(::Array{Pkg.REPLMode.QString,1}, ::Dict{Symbol,Any}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/command_declarations.jl:89
 [11] Pkg.REPLMode.Command(::Pkg.REPLMode.Statement) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/REPLMode.jl:366
 [12] iterate at ./generator.jl:47 [inlined]
 [13] _collect(::Array{Pkg.REPLMode.Statement,1}, ::Base.Generator{Array{Pkg.REPLMode.Statement,1},Type{Pkg.REPLMode.Command}}, ::Base.EltypeUnknown, ::Base.HasShape{1}) at ./array.jl:699
 [14] collect_similar at ./array.jl:628 [inlined]
 [15] map at ./abstractarray.jl:2162 [inlined]
 [16] do_cmd(::REPL.LineEditREPL, ::String; do_rethrow::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/REPLMode.jl:379
 [17] do_cmd at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/REPLMode.jl:377 [inlined]
 [18] (::Pkg.REPLMode.var"#24#27"{REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/REPLMode/REPLMode.jl:546
 [19] #invokelatest#1 at ./essentials.jl:710 [inlined]
 [20] invokelatest at ./essentials.jl:709 [inlined]
 [21] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2355
 [22] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:1144
 [23] (::REPL.var"#38#42"{REPL.LineEditREPL,REPL.REPLBackendRef})() at ./task.jl:356
KristofferC commented 3 years ago

Note that you can use

Pkg.add(url = "https://username@bitbucket.org/orgname/reponame.git", rev = "dev")
fredrikekre commented 3 years ago

Quoting should work in the Pkg REPL too:

(@v1.5) pkg> add "https://username@bitbucket.org/orgname/reponame.git#dev"
fredrikekre commented 3 years ago

Introduced by #1936, should probably allow special characters # and @ after .git too.

imikim commented 3 years ago

Quoting should work in the Pkg REPL too:

(@v1.5) pkg> add "https://username@bitbucket.org/orgname/reponame.git#dev"

this did not work for me, albeit with a different error (ERROR: failed to clone from https://username@bitbucket.org/orgname/reponame.git#dev, error: GitError(Code:ERROR, Class:Net, unexpected HTTP status code: 404))

The Pkg.add(url = "", rev="") did work

KristofferC commented 3 years ago

Maybe

add "https://username@bitbucket.org/orgname/reponame.git"#dev
owiecc commented 2 years ago

It would be nice if pasting a link from github also worked. E.g.

add https://github.com/user/Package.jl/tree/branch_id

now fails with

ERROR: failed to clone from https://github.com/user/Package.jl/tree/branch_id, error: GitError(Code:ERROR, Class:HTTP, unexpected http status code: 404)

stemann commented 3 weeks ago

"Weird" systems like Azure DevOps (which don't have .git in the end) is also broken - by default - even Pkg.add(PackageSpec(; url=..., rev=...)) fails.

It would be nice, if the default SSH URL form, username@vs-ssh.visualstudio.com:v3/username/project/repo, were identified as a URL and not a path.

For the record, the following likely-deprecated-likely-not-documented Azure DevOps URL work: git@ssh.dev.azure.com:v3/username/project/repo

Also, ssh://user@vs-ssh.visualstudio.com/v3/user/project/repo works (note the / in front of v3)