-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Normalize the target
paths
#14497
Normalize the target
paths
#14497
Conversation
e14e582
to
2fba2ad
Compare
2fba2ad
to
0b72c74
Compare
bin
table.target
paths
d71aea5
to
90753b6
Compare
ea8f33e
to
a15bb7a
Compare
In the But it is not very aceptable for I also want to apply the |
Hmm, sounds like That also makes me question using it elsewhere. I forgot that we leave these paths relative. I wonder if we should make the absolute during normalization and relative during publish. |
It's not work for
This way is trickier than I thought. |
a15bb7a
to
910d06b
Compare
9b4515c
to
ef810f6
Compare
r? @epage
See my PR description, I think this problem has been improved, please continue to review and leave valuable comments |
Looking at
its telling me what its doing. What I'm wondering is why this route was chosen. |
I have given up using this scheme and instead just absolutize the path in 'target' and do 'normalize_path'. |
FYI I posted #14750 |
src/cargo/util/toml/targets.rs
Outdated
if let Some(PathValue(path)) = lib.path.as_ref() { | ||
let path = package_root.join(path); | ||
let path = paths::normalize_path(&path); | ||
lib.path = Some(PathValue(path.into())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're doing the join
s here, should we remove the join
s in the to_
functions?
src/cargo/util/toml/targets.rs
Outdated
@@ -98,7 +99,7 @@ pub(super) fn to_targets( | |||
); | |||
targets.push(Target::custom_build_target( | |||
&name, | |||
package_root.join(custom_build), | |||
paths::normalize_path(package_root.join(custom_build).as_path()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is happening during a to_
operation while all the rest are during a normalize
operation
Waiting on this PR to be merged. If the |
fix(util): Respect all `..`s in `normalize_path` ### What does this PR try to resolve? The fact that `normalize_path` was only designed for absolute paths bit us when working out #14497 and so I decided to make sure it worked. The other alternative I considered was having it assert that the path was absolute. Since I did try out the assert and Cargo tests hit it, this likely fixes something but I haven't dug through to be able to say what. ### How should we test and review this PR? ### Additional information
This PR chose this route.
This approach requires more changes and is not ideal. If I understand you correctly, this needs absolutize the target path in the If we accept that targets path had been absolutized, then it has a big drawback in |
src/cargo/util/toml/targets.rs
Outdated
Some(StringOrBool::String(build_file)) => { | ||
let build_file = paths::normalize_path(Path::new(build_file)); | ||
let build = build_file | ||
.into_os_string() | ||
.into_string() | ||
.map_err(|_err| anyhow::format_err!("non-UTF8 `package.build`"))?; | ||
Some(StringOrBool::String(build)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message is inaccurate as package.build
can only be UTF-8 because StringOrBool::String
is a String
.
This could instead be
.expect("`build_file` started as a String and `normalize_path` shouldn't have changed that")
Thank you for your patience in this PR and working towards what is right,even if it has been a lot of churn on your side! |
@bors r+ |
☀️ Test successful - checks-actions |
Update cargo 16 commits in 0310497822a7a673a330a5dd068b7aaa579a265e..4a2d8dc636445b276288543882e076f254b3ae95 2024-11-01 19:27:56 +0000 to 2024-11-09 19:10:33 +0000 - test: adjust `cargo_test_env` to unblock rust submodule update (rust-lang/cargo#14803) - feat(warnings): add build.warnings option (rust-lang/cargo#14388) - Revert "feat: Add `CARGO_RUSTC_CURRENT_DIR`" (rust-lang/cargo#14799) - CI: make the `lint-docs` job required (rust-lang/cargo#14797) - Switch CI from bors to merge queue (rust-lang/cargo#14718) - docs(test): Document Execs assertions based on port effort (rust-lang/cargo#14793) - fix(test): Make redactions consistent with snapbox (rust-lang/cargo#14790) - test(gc): Update remaining unordered tests to snapbox (rust-lang/cargo#14785) - Normalize the `target` paths (rust-lang/cargo#14497) - rustfix: replace special-case duplicate handling with error (rust-lang/cargo#14782) - test: Update some emaining unordered tests to snapbox (rust-lang/cargo#14781) - Change config paths to only check CARGO_HOME for cargo-script (rust-lang/cargo#14749) - Enable transfer feature in triagebot (rust-lang/cargo#14777) - Add transactional semantics to `rustfix` (rust-lang/cargo#14747) - doc: fix `GlobalContext` reference (rust-lang/cargo#14773) - chore: update handlebars to v6, fix build error (rust-lang/cargo#14772)
Update cargo 16 commits in 0310497822a7a673a330a5dd068b7aaa579a265e..4a2d8dc636445b276288543882e076f254b3ae95 2024-11-01 19:27:56 +0000 to 2024-11-09 19:10:33 +0000 - test: adjust `cargo_test_env` to unblock rust submodule update (rust-lang/cargo#14803) - feat(warnings): add build.warnings option (rust-lang/cargo#14388) - Revert "feat: Add `CARGO_RUSTC_CURRENT_DIR`" (rust-lang/cargo#14799) - CI: make the `lint-docs` job required (rust-lang/cargo#14797) - Switch CI from bors to merge queue (rust-lang/cargo#14718) - docs(test): Document Execs assertions based on port effort (rust-lang/cargo#14793) - fix(test): Make redactions consistent with snapbox (rust-lang/cargo#14790) - test(gc): Update remaining unordered tests to snapbox (rust-lang/cargo#14785) - Normalize the `target` paths (rust-lang/cargo#14497) - rustfix: replace special-case duplicate handling with error (rust-lang/cargo#14782) - test: Update some emaining unordered tests to snapbox (rust-lang/cargo#14781) - Change config paths to only check CARGO_HOME for cargo-script (rust-lang/cargo#14749) - Enable transfer feature in triagebot (rust-lang/cargo#14777) - Add transactional semantics to `rustfix` (rust-lang/cargo#14747) - doc: fix `GlobalContext` reference (rust-lang/cargo#14773) - chore: update handlebars to v6, fix build error (rust-lang/cargo#14772)
What does this PR try to resolve?
The
targets
path of thenormalized_toml
could be relative, which isn't user-friendly.What is this PR doing?
This PR applys the
paths::normalize_path
to remove the relative part.Fixes #14227
How should we test and review this PR?
Add a test originted from the issue, and fixing it in the next commit.
Additional information