Skip to content

fix: Respect .cargo/config.toml build.target-dir #20072

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

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jun 23, 2025

Fixes #20070

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 23, 2025
@Veykril Veykril force-pushed the push-sorvvvzskywv branch from 8847b3c to f7a8307 Compare June 23, 2025 17:47
@Veykril Veykril added this pull request to the merge queue Jun 24, 2025
Merged via the queue into rust-lang:master with commit 937cd52 Jun 24, 2025
14 checks passed
@Veykril Veykril deleted the push-sorvvvzskywv branch June 24, 2025 06:02
}
utf8_stdout(&mut cargo_config)
.map(|stdout| {
Utf8Path::new(stdout.trim_start_matches("build.target-dir = ").trim_matches('"'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this breaks if the path contains quotes, e.g. build.target-dir = 'a " b' or build.target-dir = """a " ' b""".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. There is general cleanup potential here. For one, we invoke cargo config three times now for the different things, which is unnecessary, we can just invoke it plain and read out the info from that we want from that output. Secondly, it supports json output (and json-value though I have no idea what that means). We should just use the json output for more robust deserialization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json is {"build":{"target-dir":"a \" b"}}, json-value is "a \" b".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, it made no difference when I tested it but that was because I ran it without a target config so it returned the root object in both :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating target director in crate folder with target-dir set in .cargo/config.toml
4 participants