Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[replace] does not replace metadata (dependencies) #2603

Closed
SimonSapin opened this issue Apr 21, 2016 · 10 comments
Closed

[replace] does not replace metadata (dependencies) #2603

SimonSapin opened this issue Apr 21, 2016 · 10 comments

Comments

@SimonSapin
Copy link
Contributor

I have a branch of Servo with this override:

[replace]
"hyper:0.8.1" = {git = "https://github.com/servo/hyper", branch = "url-1.0"}

In that git branch, the Cargo.toml for hyper contains:

[dependencies]
url = "1.0"

However, hyper with my replaced sourced is built with url 0.5.9, which is the dependency declared in the original un-replaced hyper. Cargo.lock even shows this:

[[package]]
name = "hyper"
version = "0.8.1"
source = "git+https://github.com/servo/hyper?branch=url-1.0#353217402264578933dca89c0e7f210052c552a5"
dependencies = [
 […]
 "url 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
]

Where dependencies does not match what’s in the Cargo.toml file at source.

(Specifying an additional replacement for "url:0.5.9" = {git = "https://github.com/servo/rust-url", branch = "1.0.0-pretending-to-be-0.5.9"} worked, but I was trying to remove it now that url 1.0.0 is on crates.io.)

@alexcrichton
Copy link
Member

I unfortunately can't seem to reproduce this situation in a test case of Cargo. Is there a branch I could check out or an easy way for me to reproduce this locally?

@behnam
Copy link
Contributor

behnam commented May 8, 2017

I'm facing a similar issue and ./mach clean doesn't help either. Here's my situation in short:

git clone https://github.com/servo/unicode-bidi
git clone https://github.com/servo/servo

then:

  1. Edit unicode-bidi/Cargo.toml and bump the version
  2. Update dependency version in components/layout/text.rs
  3. Add following line to [replace] table in servo/Cargo.toml:
"unicode-bidi:0.3.0" = { path = "../servo-unicode-bidi" }

Here's the result:

$ ./mach clean

$ ./mach build --dev
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: no matching version `^0.3` found for package `unicode-bidi` (required by `layout`)
location searched: registry https://github.com/rust-lang/crates.io-index
versions found: 0.2.5, 0.2.4, 0.2.3, ...
Build FAILED in 0:00:03

@alexcrichton
Copy link
Member

@behnam currently [replace] only works with crates that already exist on crates.io, and it looks like 0.3.0 doesn't exist on crates.io?

@behnam
Copy link
Contributor

behnam commented May 9, 2017

Right, @alexcrichton. The 0.3.0 version is something I have locally and want to test servo against before publishing.

In servo/Cargo.toml, I see this:

[replace]
# If you need to temporarily test Servo with a local fork of some upstream
# crate, add that here. Use the form:
#
#     "<crate>:<version>" = { path = "/path/to/local/checkout" }

which sounds like exactly what I need [replace] for: overriding the source (path instead of crates.io) for the specific version for the whole build.

@behnam
Copy link
Contributor

behnam commented May 9, 2017

Interesting part is that I get a warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#... if I add a replace entry with a version that's not required. But, when the version is required by some of the components, the warning goes away, but a few seconds into the ./mach build I get the error: no matching version ... error.

@alexcrichton
Copy link
Member

@behnam ah yeah if you want to work with unpublished crates currently Cargo doesn't have support for that, but you may be interested in rust-lang/rfcs#1969 which adds support.

@behnam
Copy link
Contributor

behnam commented May 9, 2017

Okay, got it. Thanks. But wondering what this comment in servo/Cargo.toml means, then:

# If you need to temporarily test Servo with a local fork of some upstream
# crate, add that here. Use the form:

Does it mean that local path works as long as the version is published to crates.io? If so, maybe we should point it out in the comment. I can submit a PR for it.

@alexcrichton
Copy link
Member

Yeah as long as the version of the crate listed in path is the same as it is in the lock file, then you should be good to go.

@carols10cents
Copy link
Member

I unfortunately can't seem to reproduce this situation in a test case of Cargo. Is there a branch I could check out or an easy way for me to reproduce this locally?

Closing due to inactivity, if this is still an issue, please reopen with more details.

@SimonSapin
Copy link
Contributor Author

I think that the solution to this is often to use [patch] instead of [replace]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants