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 install does not ignore unstable table in .cargo/config.toml file #8512

Closed
phil-opp opened this issue Jul 19, 2020 · 5 comments · Fixed by #8656
Closed

cargo install does not ignore unstable table in .cargo/config.toml file #8512

phil-opp opened this issue Jul 19, 2020 · 5 comments · Fixed by #8656
Labels
A-configuration Area: cargo config files and env vars C-bug Category: bug Command-install

Comments

@phil-opp
Copy link
Contributor

Problem

In #6026, the behavior of cargo install was changed to ignore any.cargo/config.toml configuration in the current working directory. It seems like this behavior does not apply to the new unstable table in that config file.

Steps

  1. Create a .cargo/config.toml file with the following content:
[unstable]
build-std = ["core"]
  1. Try to install a crate from crates.io, e.g. cargo install bootimage.
  2. This results in a -Zbuild-std requires --target error.
  3. Switching to the parent directory fixes the problem because then the .cargo/config file no longer applies.

Possible Solution(s)

The unstable table should behave the same as the other .cargo/config.toml configuration keys and be ignored for cargo install. Only configuration files in the home directory and the --path directory should be considered.

Notes

Output of cargo version:

cargo 1.46.0-nightly (43cf773 2020-07-13)
release: 1.46.0
commit-hash: 43cf773
commit-date: 2020-07-13

Originally reported by @Asoftyn in rust-osdev/bootimage#64.

@ehuss
Copy link
Contributor

ehuss commented Jul 20, 2020

Thanks for the report!

@bearcage do you think you can take a look at this?

@ehuss ehuss added A-configuration Area: cargo config files and env vars Command-install labels Jul 20, 2020
@phil-opp
Copy link
Contributor Author

I looked into this a bit and it seems like the problem is that the reload_rooted_at function only updates the Config::values field, but not the Config::unstable_flags field.

I'm not sure about the best way to fix this, but a simple solution might be to store the unstable_flags argument originally passed to Config::configure in new field (e.g. unstable_flags_cli) in the Config struct. This would make it possible to re-run the parsing of these unstable flags based on the new config location in reload_rooted_at. I'm happy to create a PR for this if this approach sounds good to you.

@ehuss
Copy link
Contributor

ehuss commented Aug 26, 2020

That sounds like a good approach. Would be happy for a PR. Thanks for taking a look!

@phil-opp
Copy link
Contributor Author

Opened a PR at #8656.

@bors bors closed this as completed in d6b5b53 Aug 31, 2020
@bearcage
Copy link
Contributor

Apologies for reviving an ancient thread — sorry I didn't respond to this @ehuss! This notif landed at a time I'd been auto-subscribed to a whole mess of internal repos at work and ended up declaring github-notification-bankruptcy (marking everything read).

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 C-bug Category: bug Command-install
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants