Pkg.jl icon indicating copy to clipboard operation
Pkg.jl copied to clipboard

Pkg.add() and `add` slightly different results

Open cormullion opened this issue 1 year ago • 4 comments

Sorry if this a FAQ - are Pkg.add() and add do different things?

Here, Pkg.add() adds a "#master" at the end, whereas add doesn't.

    (@MiniFB) pkg> add https://github.com/oheil/Luxor.jl#multi_drawing
        Updating git-repo `https://github.com/oheil/Luxor.jl`
       Resolving package versions...
        Updating `~/.julia/environments/MiniFB/Project.toml`
      [ae8d54c2] ~ Luxor v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing#master` ⇒ v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing`
        Updating `~/.julia/environments/MiniFB/Manifest.toml`
🔴      [ae8d54c2] ~ Luxor v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing#master` ⇒ v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing`
    Precompiling project...
      ✓ Luxor
      1 dependency successfully precompiled in 4 seconds. 82 already precompiled.
      1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version
    
    (@MiniFB) pkg> st
    Status `~/.julia/environments/MiniFB/Project.toml`
      [5ae59095] Colors v0.12.8
      [ae8d54c2] Luxor v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing`
      [cc649173] MiniFB v0.1.1
    
    julia> Pkg.add(path="https://github.com/oheil/Luxor.jl#multi_drawing")
        Updating git-repo `https://github.com/oheil/Luxor.jl#multi_drawing`
       Resolving package versions...
        Updating `~/.julia/environments/MiniFB/Project.toml`
      [ae8d54c2] ~ Luxor v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing` ⇒ v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing#master`
        Updating `~/.julia/environments/MiniFB/Manifest.toml`
🔴      [ae8d54c2] ~ Luxor v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing` ⇒ v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing#master`
    Precompiling project...
      ✓ Luxor
      1 dependency successfully precompiled in 3 seconds. 82 already precompiled.
      1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version
    
    (@MiniFB) pkg> st
    Status `~/.julia/environments/MiniFB/Project.toml`
      [5ae59095] Colors v0.12.8
      [ae8d54c2] Luxor v3.5.0 `https://github.com/oheil/Luxor.jl#multi_drawing#master`
      [cc649173] MiniFB v0.1.1

cormullion avatar Jul 19 '22 10:07 cormullion

Pkg.add(path="https://github.com/oheil/Luxor.jl#multi_drawing")

This is spelled Pkg.add(url = "https://github.com/oheil/Luxor.jl", rev = "multi_drawing"). It is at least hinted to here: https://pkgdocs.julialang.org/v1/api/#Package-API-Reference. The Pkg REPL is meant for interactive use, so it tries to be a bit more "clever" compared to the API, which you have to tell exactly what you mean.

fredrikekre avatar Jul 19 '22 11:07 fredrikekre

Ah, OK, thanks! I was just automating some manual typing, and translated it carelessly... Feel free to close this if you want.

cormullion avatar Jul 19 '22 11:07 cormullion

Perhaps Pkg.add(path="https://github.com/oheil/Luxor.jl#multi_drawing") should error instead of just ignoring part of the (malformed) input?

giordano avatar Jul 26 '22 01:07 giordano

Problem is that it is a a valid URL though.

Edit: Although from Wikipedia:

[...] Clients are not supposed to send URI fragments to servers when they retrieve a document [...]

curl drops it silently, git errors.

fredrikekre avatar Jul 26 '22 08:07 fredrikekre