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 uses .cargo/config of workspace from which it is excluded #7620

Closed
stevenroose opened this issue Nov 22, 2019 · 3 comments
Closed

Cargo uses .cargo/config of workspace from which it is excluded #7620

stevenroose opened this issue Nov 22, 2019 · 3 comments
Labels
A-configuration Area: cargo config files and env vars A-source-replacement Area: [source] replacement A-workspaces Area: workspaces C-bug Category: bug

Comments

@stevenroose
Copy link

So we have a big cargo workspace, let's say in /workspace/. We have /workspace/vendor and /workspace/.cargo/config which points crates-io to this vendor directory. In /workspace/Cargo.toml we exclude one directory from the workspace:

exclude = [
    "excluded"
]

So, when I go into /workspace/excluded and I try to run cargo build, I'm getting these kind of errors:

error: failed to select a version for the requirement `libc = "^0.2.62"`
  candidate versions found which didn't match: 0.2.50
  location searched: directory source `/workspace/vendor` (which is replacing registry `https://github.com/rust-lang/crates.io-index`)
required by package `excluded v0.1.0 (/workspace/excluded)`
perhaps a crate was updated and forgotten to be re-vendored?

So it seems that the source replacement from .cargo/config is seen as totally separate from the workspace concept. This if of course very annoying and I would consider it a bug. A directory excluded from the workspace should not use configs that are set in the workspace directory.

@stevenroose stevenroose added the C-bug Category: bug label Nov 22, 2019
@sfackler
Copy link
Member

Cargo searches all parent directories for a .cargo directory, whether or not they're part of the workspace IIRC.

@stevenroose
Copy link
Author

Correct. In my opinion that doesn't make sense. Somehow vendor directories should be linkable with workspaces instead of entirely independent.

@ehuss ehuss added A-configuration Area: cargo config files and env vars A-source-replacement Area: [source] replacement A-workspaces Area: workspaces labels Dec 3, 2019
@epage
Copy link
Contributor

epage commented Nov 3, 2023

As the config is an environment config, rather than a project config, this is working as expected. This is a common point of confusion though and we have many other issues tracking this. Closing in favor of #2930 so we consolidate conversations about the config lookup rules

See also #12738 for tracking efforts in finding ways to store settings in the project that is currently only supported in the environment.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars A-source-replacement Area: [source] replacement A-workspaces Area: workspaces C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants