Skip to content

Cargo doesn't support config relative paths for rustc|rustc_wrapper|rustc_workspace_wrapper|rustdoc #8202

@rickvanprim

Description

@rickvanprim

Problem
When attempting to set a relative path for rustc|rustc_wrapper|rustc_workspace_wrapper|rustdoc in the Cargo Config [build] section, the build is dependent on the working directory Cargo chooses for any given build step. As a result, running cargo build --manifest-path=my_workspace_crate/Cargo.toml from the workspace root doesn't work because part of the process looks for rustc relative to the root of the workspace, and part looks relative to the root of my_workspace_crate.

Steps

  1. Set a relative path for rustc inside .cargo/config
  2. Attempt to build a crate where working directory is the root of that crate.
  3. Run cargo clean.
  4. Attempt to build the same crate from a different working directory by specifying --manifest-path or as part of a workspace.
  5. Observe build fails due to not being able to find rustc.

Possible Solution(s)
Inside of src/cargo/util/config/mod.rs change CargoBuildConfig's rustc|rustc_wrapper|rustc_workspace_wrapper|rustdoc from Option<PathBuf> to Option<ConfigRelativePath>

Notes

Output of cargo version: cargo 1.44.0-nightly (8751eb3 2020-04-21)

Metadata

Metadata

Assignees

Labels

A-configurationArea: cargo config files and env varsC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions