-
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
Don't canonicalize executable path #9991
Don't canonicalize executable path #9991
Conversation
Otherwise symbolic links may also accidentally be resolved which may lead to unexpected results in the case of 'coreutils', a binary that depends on the executable name being a symbolic link. This means a path like /bin/echo being canonicalized to /bin/coreutils will loose all information about the desired functionality. Test failures will occur if 'echo' is resolved that way and it's not trivial to find the cause of it in the provided error messages.
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
Might it make sense to get the directory name of the path, canonicalize that, then re-append the basename? That would allow unconditionally canonicalizing without affecting |
@joshtriplett I very much like the idea, and think it would be great to do that transformation right before trying to canonicalize the path. This means it would still avoid any canonicalization if there is seemingly no need due to the lack of relative path components. If that sounds good, I can adjust the PR accordingly. |
…looking if it does.
Typically in Cargo we're very wary of the It turns out this is somewhat of a storied history. From what I can tell the From looking at the history I don't know of any reason why we need to use |
@alexcrichton Great detective work! I have put it to the test, removing canonicalization entirely. |
@Byron There's another call to canonicalize a few lines later. |
And here is why: rust-lang#9991 (comment)
f4e8ec8
to
cf8e464
Compare
@bors r+ |
📌 Commit cf8e464 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 4 commits in 7fbbf4e8f23e3c24b8afff541dcb17e53eb5ff88..6c1bc24b8b49d4bc965f67d7037906dc199c72b7 2021-10-19 02:16:48 +0000 to 2021-10-24 17:51:41 +0000 - Fix a clippy warning (rust-lang/cargo#10002) - Upgrade Cargo to the 2021 edition (rust-lang/cargo#10000) - Don't canonicalize executable path (rust-lang/cargo#9991) - Bump to 0.59.0, update changelog (rust-lang/cargo#9998)
Otherwise symbolic links may also accidentally be resolved which may lead to unexpected results in the case of 'coreutils', a binary that depends on the executable name being a symbolic link.
This means a path like /bin/echo being canonicalized to /bin/coreutils will loose all information about the desired functionality.
For example, test failures will occur if 'echo' is resolved that way and it's not trivial to find the cause of it in the provided error messages. For example
doc_workspace_open_different_library_and_package_names
did fail for me on MacOS, Nix packages in PATH, but works with this patch.With this patch, there is still the possibility that a path gets canonicalized for its relative path components, but still results in changing the name of the binary. I could imagine to check for binary name changes and panic if
coreutils
orbusybox
is encountered, which are known to fail without a symlink telling them which program to emulate.