Skip to content

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

@nipunn1313

Description

@nipunn1313

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.

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