-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix: display absolute path in the missing in PATH warning
#16125
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
base: master
Are you sure you want to change the base?
Conversation
daf3b81 to
9e4b6b4
Compare
b141907 to
7867550
Compare
missing in PATH warning
8995ab9 to
34cc964
Compare
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.
🔢 Self-check (PR reviewed by myself and ready for feedback)
-
Code compiles successfully
-
Unit tests added
-
All tests pass
-
Comments added where necessary
-
Logs added where necessary
-
PR title and description updated
-
Documentation PR created (or confirmed not needed)
-
PR size is reasonable
080a4e7 to
24904ce
Compare
24904ce to
fb0690b
Compare
cb41a3f to
dc89d66
Compare
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 final diff looks actually clearer than the commit history. Not sure the history was intended that way, though I feel like we might want a fixup.
Anyway, thanks for fixing this!
| fs::remove_file(root.join(".cargo/config.toml")).unwrap(); | ||
| fs::remove_dir_all(&project_t1).unwrap(); |
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 mutates the test state. Should we have it as a separate test instead?
| } | ||
|
|
||
| #[cargo_test] | ||
| fn relative_install_location_with_path_set() { |
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.
Would you mind having this test created before the fix? Otherwise it is a bit hard to tell where there was a bug and we are really fixing it.
| let definition = p.value().definition.clone(); | ||
| if matches!(definition, Definition::Path(_)) { | ||
| let suggested = format!("{}/", resolved.display()); | ||
| let notes = vec![ |
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.
array should be good enough,
and later no need to call into_iter()?
| let notes = vec![ | |
| let notes = [ |
| let dst_path = root.join("bin").into_path_unlocked(); | ||
| let cwd = gctx.cwd(); | ||
| let dst = if dst_path.is_absolute() { | ||
| paths::normalize_path(dst_path.as_path()) | ||
| } else { | ||
| paths::normalize_path(&cwd.join(&dst_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.
nit: This function is too long and I am afraid of misuse of dst_path again. Perpahs we call it dst as well to avoid that?
| let dst_path = root.join("bin").into_path_unlocked(); | |
| let cwd = gctx.cwd(); | |
| let dst = if dst_path.is_absolute() { | |
| paths::normalize_path(dst_path.as_path()) | |
| } else { | |
| paths::normalize_path(&cwd.join(&dst_path)) | |
| }; | |
| let dst = root.join("bin").into_path_unlocked(); | |
| let cwd = gctx.cwd(); | |
| let dst = if dst.is_absolute() { | |
| paths::normalize_path(dst.as_path()) | |
| } else { | |
| paths::normalize_path(&cwd.join(&dst)) | |
| }; |
|
|
||
| let dst = self.root.join("bin").into_path_unlocked(); | ||
| // `dst` is usually absolute; if not, make it absolute so messages are clearer. | ||
| // See: https://github.com/rust-lang/cargo/issues/16023 |
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 two duplicate make-absolute code actually fix two different warnings, should we make one commit for each to make the intent more obvious?
What does this PR try to resolve?
close #16023
Improve the warning message for realtive install location.
install.rootpaths without a trailing backslash will be deprecated in the future.How to test and review this PR?
Please check the unit test.
r?@ghost