Skip to content

'cargo update -p foo' fails with [patch]’ed depenedency #4315

Closed
@SimonSapin

Description

@SimonSapin

servo/rust-cssparser#171 makes a number of changes to the cssparser crate, including changing its version number from 0.17.0 to 0.18.0. That PR has not landed yet, 0.18.0 is not on crates.io yet. I want to test it in Servo beforehand. I already had a Servo branch with [replace] (and a separate cssparser branch with a silly commit that reverses the version number change…) Now that rust-lang/rust#43319 has landed, I tried [patch] instead.

Starting from Servo master, I changed cssparser = "0.17" to cssparser = "0.18" in a dozen Cargo.toml files, added the lines below to the workspace’s Cargo.toml, and cherry-picked the commits updating the code for API changes.

[patch.crates-io]
cssparser = {git = "https://github.com/servo/rust-cssparser", rev = "token-cache"}

At this point, with [replace], I’d usually need to run cargo update -p cssparser to get Cargo.lock in a state consistent with toml files. This fails:

% cargo update -p cssparser
    Updating git repository `https://github.com/servo/rust-cssparser`
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: no matching version `^0.18` found for package `cssparser` (required by `style_traits`)
location searched: registry https://github.com/rust-lang/crates.io-index
versions found: 0.17.0, 0.16.1, 0.16.0, ...

Though cargo build succeeds, so it looks like [patch] is working as intended. It’s only the update sub-command that apparently still needs to learn about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions