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

Cargo varies between absolute/relative path passing vendor dir to rustc #5923

Closed
nipunn1313 opened this issue Aug 22, 2018 · 2 comments · Fixed by #5935
Closed

Cargo varies between absolute/relative path passing vendor dir to rustc #5923

nipunn1313 opened this issue Aug 22, 2018 · 2 comments · Fixed by #5935

Comments

@nipunn1313
Copy link
Contributor

Here's the setup with two workspaces

.cargo
   config
w1/
   Cargo.toml
   vendor/
w2/
   Cargo.toml

The .cargo/config points to

[source.vendored-sources]
directory = "./w1/vendor"

When compiling something in w1, the command line might look like this:

rustc --crate-name byteorder vendor/byteorder-1.1.0/src/lib.rs

When compiling something in w2 the command line might look like this

rustc --crate-name byteorder /Users/nipunn/src/client/rust/vendor/byteorder-1.1.0/src/lib.rs

Given that I share a CARGO_HOME across these two, and AFAICT, the cargo dep caching is based on rustc command line, if I alternate between compiling these two, it kicks off full recompiles.

If I move the vendor directory up to root, they both use absolute paths, and deps are cached across the two projects.

Proposed solution: cargo should always pass an absolute path to the vendor directory to rustc to work around this issue.

@dwijnand
Copy link
Member

Similar (but distinct) to #5895, which is about relative paths in error messages.

@nipunn1313
Copy link
Contributor Author

For anyone else running into this:
our workaround was to move the vendor directory outside of all of our workspaces (in our case the top level). This avoids dep recompiles when switching between workspaces that share a vendor dir.

alexcrichton added a commit to alexcrichton/cargo that referenced this issue Aug 24, 2018
Previously Cargo would use a non-absolute path for any dependency contained
within the workspace root but this switches Cargo to only using relative paths
for `path` dependencies. In practice this shouldn't make much difference, but
for vendored crates and moving around `CARGO_HOME` it can produce more
consistent results when target directories are shared.

Closes rust-lang#5923
bors added a commit that referenced this issue Aug 24, 2018
Only use non-absolute paths for `path` dependencies

Previously Cargo would use a non-absolute path for any dependency contained
within the workspace root but this switches Cargo to only using relative paths
for `path` dependencies. In practice this shouldn't make much difference, but
for vendored crates and moving around `CARGO_HOME` it can produce more
consistent results when target directories are shared.

Closes #5923
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

Successfully merging a pull request may close this issue.

2 participants