-
Notifications
You must be signed in to change notification settings - Fork 490
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(env): use unix paths in windows bash, zsh, fish #724
Conversation
I forgot to say thanks in advance for this contribution. Really good stuff! |
|
Adding new flags Running |
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.
maybe it's not a shell concern but environment one. I'm sorry that I'm requesting changes like a pendulum but I'm thinking about the problem as I'm reviewing the code. Really appreciate the contribution!
src/shell/powershell.rs
Outdated
@@ -48,4 +49,8 @@ impl Shell for PowerShell { | |||
fn to_clap_shell(&self) -> clap_complete::Shell { | |||
clap_complete::Shell::PowerShell | |||
} | |||
|
|||
fn format_path(&self, path: &str) -> Result<String> { | |||
Ok(path.to_string()) |
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.
powershell can be run on Mac and Linux (not sure about usage though). Maybe we need to call unixpath
here too? We probably can't know if we're in WSL or Cygwin, or do we? based on the infer_shell infra and the process-walking method?
What I'm thinking is--maybe it's not shell-related, but environment related, and therefore if we have this information?
We can start without any inference, so it will require the following, if one wants to use the Windows version of fnm within Cygwin or WSL:
fnm env --path-formatter=cygwin
fnm env --path-formatter=wsl
what do you think about it?
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.
Powershell actually uses the correct path format for each platform so we don't have to convert the path to the right format. The windows shell inference code that we have breaks when run in WSL, so inferring isn't possible without reworking that somehow and I can't think of any way to do that currently, but for now I can implement it with flags.
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.
Actually, I figured out a way to detect if the executable is being run from WSL, but inferring the shell is not possible and the user needs to provide it as a flag (maybe there can be a custom error message for it).
Detecting WSL works the same way as shell inferring, at some point up the parent process chain there is a process named "wsl.exe", but there's no information on the shell being used.
I just realized running |
Superseded by #960 , sorry |
Related to #390.
Fix environment variable generation for
fnm env
in Windows.Cygwin, MSYS, and Git Bash use UNIX-style paths (like
/c/Users/username/AppData/Local/fnm_multishells
), but fnm generates Windows-style paths (likeC:\Users\username\AppData\Local\fnm_multishells
) in Windows, regardless of the shell.With these changes, fnm can convert paths to UNIX using
cygpath
in bash, zsh, and fish, but leave Windows paths alone in pwsh and cmd.