-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(shell): create parent dir before appending to rcfiles #3712
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 doesn't obviously make sense to me. Why is this necessary? At the very least deserves some more comments on why we're doing this.
Uh oh!
There was an error while loading. Please reload this page.
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.
@djc Sure! The snippet below explains the differences between
.rcfiles()and.update_rcs().rustup/src/cli/self_update/shell.rs
Lines 91 to 96 in 3fcd562
The problem with the current code is that, we have two rc paths in fish, one (
p1) being the fallback of the other (p0).rustup/src/cli/self_update/shell.rs
Lines 218 to 230 in 3fcd562
The issue here is, according to the current implementation, if both paths are valid, then we'll create and append to both of them. (It's okay to check both paths for cleanup, but that's another story.)
rustup/src/cli/self_update/unix.rs
Lines 88 to 93 in f6dbe2e
This is the expected behavior in some cases, but clearly not for fish due to this fallback relationship. I've found some similar code in the Zsh support (note the
.take(1)):rustup/src/cli/self_update/shell.rs
Lines 186 to 191 in f6dbe2e
rustup/src/cli/self_update/shell.rs
Lines 193 to 205 in f6dbe2e
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.
So should we change
update_rcs()to yieldPathBufinstead ofVec<PathBuf>? It seems conceptually confusing to do this only for some shells -- do we update all rcs forBash?Anyway, I guess this change is fine, but let's add some comments to explain the logic.
This way of writing it avoids the
cloned(), and thus seems cleaner to me:What do you think?
Uh oh!
There was an error while loading. Please reload this page.
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.
@djc I'm not a bash expert, but at least the implementation is a bit more complex with Bash indeed, which seems to consider what exists on the current file system as a file and what doesn't.
rustup/src/cli/self_update/shell.rs
Lines 138 to 152 in f6dbe2e
... a quick blame points to #2387. @workingjubilee maybe you can provide more context on this one?
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.
@djc Done.
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.
@workingjubilee Thanks for your quick response! Apart from what you said above, we are particularly curious about why
update_rcsis plural 👀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.
... and that's exactly why we need this context to evaluate our fish support implementation :]
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.
Why would it be singular?
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.
It was just my intuition that it wouldn't make sense to "update" multiple RC files per shell? It seems like if we want to make the rustup proxies work in fish, it would be enough if we update one file? So in that sense
update_rcs() -> Vec<PathBuf>should be more likeupdate_rc() -> PathBuf?(I'm not big on shell customization so my understanding might be wrong.)
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.
@djc While imprecise on technical terms, my remarks in #3256 (comment) remain an accurate summary of the actual situation. In short: No. Not at all. That requires knowledge of not only the OS, not only the shell (and we don't actually know that), but the specific version and distribution of the software.