Example:
julia> using Pkg
julia> Pkg.add(PackageSpec(name="Example", url="https://github.com/JuliaLang/Example.jl", version=v"0.3.0"))
Updating registry at `~/.julia/registries/General`
Updating git-repo `https://github.com/JuliaRegistries/General.git`
Cloning git-repo `https://github.com/JuliaLang/Example.jl`
Updating git-repo `https://github.com/JuliaLang/Example.jl`
Resolving package versions...
Updating `~/.julia/environments/v1.0/Project.toml`
[7876af07] + Example v0.5.1+ #master (https://github.com/JuliaLang/Example.jl)
Updating `~/.julia/environments/v1.0/Manifest.toml`
[7876af07] + Example v0.5.1+ #master (https://github.com/JuliaLang/Example.jl)
(v1.0) pkg> status
Status `~/.julia/environments/v1.0/Project.toml`
...
[7876af07] Example v0.5.1+ #master (https://github.com/JuliaLang/Example.jl)
...
Noticed by @omus in https://github.com/JuliaLang/Pkg.jl/pull/799#issuecomment-434823318.
What should happen?
The version is provided, shouldn't it install that version?
Since versions only make sense for registered packages, the fact that you are providing an URL likely means that is what you want to use. It would make sense to warn or error when a version keyword is given and the same time as the URL though.
Since versions only make sense for registered packages, the fact that you are providing an URL likely means that is what you want to use.
If the URL is a git repo and the version is a git tag, would it not make sense to just check out that tag after cloning? You're still using the given URL, but you're also making use of the other information provided. That seems like sensible behavior to me.
If the URL is a git repo and the version is a git tag, would it not make sense to just check out that tag after cloning?
Isn't this what Pkg.add(PackageSpec(..., rev = "v0.3.0")) is for?
That is a weird distinction...
A version is not simply a git tag. Then it would be mutable, anyone can rename / delete git tags. A version is identified with a content hash.
There are two options for this scenario.
1.) Error / warn.
2) Clone the package, look up the UUID in the package Project file, search the registries, find the content hash for the version, redownload (or checkout) a version with that content.
2) Seems kinda useless since if it exist in the registry it is much simpler to add by name.
It would make sense to warn or error when a version keyword is given and the same time as the URL though.
I'm in favor of throwing an exception as the user has made a mistake and the end result won't be what they expected.
julia> Pkg.PackageSpec(name="Example", url="https://github.com/JuliaLang/Example.jl", version=v"0.3.0")
ERROR: `version` can not be given with `url`, use `rev` instead
Stacktrace:
[1] pkgerror(::String) at /tmp/Pkg.jl/src/Types.jl:120
[2] #Package#72(::String, ::Nothing, ::VersionNumber, ::String, ::Nothing, ::Nothing, ::Pkg.Types.PackageMode, ::Function) at /tmp/Pkg.jl/src/API.jl:552
[3] (::getfield(Pkg.API, Symbol("#kw##Package")))(::NamedTuple{(:name, :url, :version),Tuple{String,String,VersionNumber}}, ::typeof(Pkg.API.Package)) at ./none:0
[4] top-level scope at none:0
Thanks David!
Welcome :grin:
Most helpful comment
I'm in favor of throwing an exception as the user has made a mistake and the end result won't be what they expected.