-
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
Fix warning suppression for config.toml vs config compat symlinks #13793
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
Please add all test cases in the initial commit, passing. This should show what the current behavior is. As the commits are made that change behavior, the test cases will then be updated to pass with the behavior changes. This has a couple of benefits
|
OK. When should I rebase the branch then? Normally I wouldn't do that without an OK from the reviewers. |
yes, please |
OK. Thanks everyone for the comments. LMK about the |
"symlink A to B" is confusing; it is ambiguous (at leaset to me) whether it means A -> B or B -> A. And I'm about to introduce a function that does the reverse, and also one that makes a relative rather than full path link. So rename this function.
I've revised this and rebased/reordered it, as discussed. While I was writing the code, I felt dirty writing |
Err, I have discovered a mistake. Give me a moment, will rewind this again. Sorry. |
I think this is ready now. CI failures are unrelated. |
This is 100% reliable on Unix, and better on Windows. (In this commit I avoid reindenting things to make review easier; the formatting will be fixed in the next commit.) Fixes rust-lang#13667
Apply deferred indentation changes. Whitespace change only.
@bors r+ |
Fix warning suppression for config.toml vs config compat symlinks ### What does this PR try to resolve? Background: the cargo config file is being renamed from `.cargo/config` to `.cargo/config.toml`. There's code in new cargo to look for both files (for compatibility), to issue a warning when onliy the old filename is found, and also to issue a warning if both files are found. The warning suggests making a symlink if compatibility with old cargo is wanted. An attempt was made to detect when both the old and new files exists, but one is a symlink to the other, but as reported in #13667, this code is not effective. (It would work only if the symlink had the precise absolute pathname that cargo has decided to use for the lookup, which would be an unnatural way to make the link.) Logically, the warning should appear when both files exist *but are different*. That is the anomalous situation that will generate confusing behaviour. By "different" we ought to mean "aren't the very same file". That's what this MR implements, where possible. On Unix, we use the information from stat(2). That's not available on other platforms; on those, we arrange to also tolerate a symlink referring to precisely `config.toml` as a relative pathname, which is also fine, since by definition the target is then in the same directrory as `config`. Fixes #13667. ### How should we test and review this PR? I have interleaved the new tests with the commits that support them. In each case, a functional commit is followed by a test which fails just beforehand. (This can be observed by experimentally reordering the branch.) I have also done ad-hoc testing. ### Additional information I'm making the assumption that a symlink containing a relative path does something sane on Windows. This assumption may be unwarranted. If so, "Handle `config` -> `config.toml` (without full path)" needs to be dropped, and the test case needs to be `#[cfg(unix)]`. But also, in this case, we should probably put some warnings in the stdlib docs!
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
Update cargo 9 commits in c9392675917adc2edab269eea27c222b5359c637..b60a1555155111e962018007a6d0ef85207db463 2024-04-23 19:35:19 +0000 to 2024-04-26 16:37:29 +0000 - fix(toml): Remove underscore field support in 2024 (rust-lang/cargo#13804) - fix: emit 1.77 syntax error only when msrv is incompatible (rust-lang/cargo#13808) - docs(ref): Index differences between virtual / real manifests (rust-lang/cargo#13794) - refactor(toml): extract dependency-to-source-id to function (rust-lang/cargo#13802) - Add where lint was set (rust-lang/cargo#13801) - fix(toml): Don't double-warn when underscore is used in workspace dep (rust-lang/cargo#13800) - fix(toml): Be more forceful with underscore/dash redundancy (rust-lang/cargo#13798) - Fix warning suppression for config.toml vs config compat symlinks (rust-lang/cargo#13793) - Cleanup linting system (rust-lang/cargo#13797) r? ghost
Update cargo 9 commits in c9392675917adc2edab269eea27c222b5359c637..b60a1555155111e962018007a6d0ef85207db463 2024-04-23 19:35:19 +0000 to 2024-04-26 16:37:29 +0000 - fix(toml): Remove underscore field support in 2024 (rust-lang/cargo#13804) - fix: emit 1.77 syntax error only when msrv is incompatible (rust-lang/cargo#13808) - docs(ref): Index differences between virtual / real manifests (rust-lang/cargo#13794) - refactor(toml): extract dependency-to-source-id to function (rust-lang/cargo#13802) - Add where lint was set (rust-lang/cargo#13801) - fix(toml): Don't double-warn when underscore is used in workspace dep (rust-lang/cargo#13800) - fix(toml): Be more forceful with underscore/dash redundancy (rust-lang/cargo#13798) - Fix warning suppression for config.toml vs config compat symlinks (rust-lang/cargo#13793) - Cleanup linting system (rust-lang/cargo#13797) r? ghost
What does this PR try to resolve?
Background: the cargo config file is being renamed from
.cargo/config
to.cargo/config.toml
. There's code in new cargo to look for both files (for compatibility), to issue a warning when onliy the old filename is found, and also to issue a warning if both files are found. The warning suggests making a symlink if compatibility with old cargo is wanted.An attempt was made to detect when both the old and new files exists, but one is a symlink to the other, but as reported in #13667, this code is not effective. (It would work only if the symlink had the precise absolute pathname that cargo has decided to use for the lookup, which would be an unnatural way to make the link.)
Logically, the warning should appear when both files exist but are different. That is the anomalous situation that will generate confusing behaviour. By "different" we ought to mean "aren't the very same file".
That's what this MR implements, where possible. On Unix, we use the information from stat(2). That's not available on other platforms; on those, we arrange to also tolerate a symlink referring to precisely
config.toml
as a relative pathname, which is also fine, since by definition the target is then in the same directrory asconfig
.Fixes #13667.
How should we test and review this PR?
I have interleaved the new tests with the commits that support them. In each case, a functional commit is followed by a test which fails just beforehand.
(This can be observed by experimentally reordering the branch.)
I have also done ad-hoc testing.
Additional information
I'm making the assumption that a symlink containing a relative path does something sane on Windows. This assumption may be unwarranted. If so, "Handle
config
->config.toml
(without full path)" needs to be dropped, and the test case needs to be#[cfg(unix)]
.But also, in this case, we should probably put some warnings in the stdlib docs!