Skip to content

cargo update SPEC broken if branch name contains plus sign #14779

Closed as not planned
@kaspar030

Description

@kaspar030

Problem

I have a crates.io patch pointing to a git repo and branch, and the branch name contains a plus sign.

That plus sign seems to break cargo update MY_DEP: (cargo update works fine)

urlplussign-bin on  main took 1s50ms 
❯ cargo update
    Updating git repository `https://github.com/kaspar030/urlplussign-lib`
    Updating crates.io index
     Locking 1 package to latest compatible version
    Removing urlplussign-lib v0.1.0 (https://github.com/kaspar030/urlplussign-lib?branch=main plus#2ff09b40)
      Adding urlplussign-lib v0.1.0 (https://github.com/kaspar030/urlplussign-lib?branch=main+plus#2ff09b40)
urlplussign-bin on  main took 1s4ms 
❯ cargo update urlplussign-lib
    Updating git repository `https://github.com/kaspar030/urlplussign-lib`
error: Unable to update https://github.com/kaspar030/urlplussign-lib?branch=main plus

Caused by:
  failed to fetch into: /home/kaspar/.cargo/git/db/urlplussign-lib-a84c539888aebb72

Caused by:
  '+refs/heads/main plus:refs/remotes/origin/main plus' is not a valid refspec.; class=Invalid (3)

Steps

I've built a minimal reproducer repo:

  1. git clone https://github.com/kaspar030/urlplussign-bin
  2. cd urlplussign-bin
  3. cargo update urlplussign-lib # fails
  4. cargo update # succeeds

Possible Solution(s)

No response

Notes

The plain cargo update output looks weird, too:

    Removing urlplussign-lib v0.1.0 (https://github.com/kaspar030/urlplussign-lib?branch=main plus#2ff09b40)
      Adding urlplussign-lib v0.1.0 (https://github.com/kaspar030/urlplussign-lib?branch=main+plus#2ff09b40)

Note how it is Removing w/o plus sign, adding with plus sign, for the same branch.

Version

❯ cargo version --verbose
cargo 1.82.0 (8f40fc59f 2024-08-21)
release: 1.82.0
commit-hash: 8f40fc59fb0c8df91c97405785197f3c630304ea
commit-date: 2024-08-21
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Arch Linux Rolling Release [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lockfileArea: Cargo.lock issuesC-bugCategory: bugS-propose-closeStatus: A team member has nominated this for closing, pending further input from the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions