-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't normalize paths in backtraces to be relative to the cwd. #47057
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 normalize paths in backtraces to be relative to the cwd. #47057
Conversation
Though this code is well intended, it is the only place in the backtrace code where we depend on local file system interaction. By adding this normalization, it becomes harder to use this code in environments where there is no current working directory (i.e., freestanding environments or sandboxed environments, such as CloudABI). I suspect that printing absolute paths here is also useful to prevent confusion and to make it easier to copy-paste and use paths between separate terminal sessions.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @sfackler (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Why is this a problem on targets without a filesystem? Wouldn't |
Hi Steven, That is a good question! With CloudABI's C/C++ environment, we've so far taken the path of omitting features that cannot be implemented sanely in our environment. For example, we don't provide
As Rust is a compiled language, just like C/C++, I would strongly suggest to continue with this approach with Rust+CloudABI as well. Unfortunately, it seems that libstd's file system bits have not been designed with POSIX My hope is that this work will eventually spawn a discussion about what an Back to the change at hand: if this feature is considered important enough to justify a dependency on file systems, I can also make this conditional on |
It is totally unacceptable to make the behavior of mainstream targets worse because it's more convenient to implement something for a new experimental target. |
Whether this change makes things better or worse is purely a matter of taste, right? Regardless of supporting CloudABI, I always prefer if full paths are displayed, as this makes working with multiple terminals, a separate editor/IDE, etc. easier. I tend to copy-paste paths around a lot: open new terminal, Do you want me to make this conditional on |
That is a way to do it, yes. |
As discussed in the pull request, there is a desire to leave this functionality intact. Decompose output_fileline() into two functions. Provide a custom implementation of the second function on CloudABI, so that we always print absolute paths on that platform.
Done. Thanks for the quick replies so far! |
Oh, wait. We're not allowed to mix generic code with target specific code in Now I'm starting to get a bit puzzled about what's the nicest way to support this. Would it make sense to push this logic into |
Happy new year from triage, @sfackler! Will you be able to finish checking this out sometime? |
Let's close this pull request, as this change will become (temporarily) unnecessary after #47268 lands. Thanks for your input anyway! |
Though this code is well intended, it is the only place in the backtrace
code where we depend on local file system interaction. By adding this
normalization, it becomes harder to use this code in environments where
there is no current working directory (i.e., freestanding environments
or sandboxed environments, such as CloudABI).
I suspect that printing absolute paths here is also useful to prevent
confusion and to make it easier to copy-paste and use paths between
separate terminal sessions.