I have fd 7.4.0 installed on a Windows machine (Rust 1.41.0, stable-x86_64-pc-windows-msvc) and run it from a bash that is provided by Git for Windows, which itself is based on Msys2 (according to https://github.com/git-for-windows/git/wiki/Technical-overview):
$ uname -a
MINGW64_NT-10.0-18363 SOMEHOST 3.0.7-338.x86_64 2019-07-03 15:16 UTC x86_64 Msys
$ fd
bar
bar\baz
bar\baz\bla
bar\baz\bla\some.txt
bar\yetanother.txt
other.txt
fd is using backslashes as it is supposed to do in Windows. #429 added the --path-separator option, which could be useful for using the results as paths within Git Bash. However, in my environment, the option fails, and every backslash is substituted with the absolute path to the Git for Windows installation directory:
$ fd --path-separator="/"
bar
barC:/Program Files/Git/baz
barC:/Program Files/Git/bazC:/Program Files/Git/bla
barC:/Program Files/Git/bazC:/Program Files/Git/blaC:/Program Files/Git/some.txt
barC:/Program Files/Git/yetanother.txt
other.txt
$ ls "C:/Program Files/Git/"
bin/ cmd/ dev/ etc/ git-bash.exe* git-cmd.exe* LICENSE.txt mingw64/ ReleaseNotes.html tmp/ unins000.dat unins000.exe* unins000.msg usr/
Using single-quotes around the slash character make no difference. Nor does leaving out the quotes all together.
It looks to me like this is a problem of Msys2 or Git Bash. Could you please try these suggestions: https://stackoverflow.com/a/54924640/704831 ?
Thank you, that was a great hint, @sharkdp! I am very grateful to you for taking the time to dig into this.
For the record, one needs to set the environment variable MSYS_NO_PATHCONV=1:
$ fd --path-separator='/'
bar
barC:/Program Files/Git/baz
barC:/Program Files/Git/bazC:/Program Files/Git/bla
barC:/Program Files/Git/bazC:/Program Files/Git/blaC:/Program Files/Git/some.txt
barC:/Program Files/Git/yetanother.txt
other.txt
$ MSYS_NO_PATHCONV=1 fd --path-separator='/'
bar
bar/baz
bar/baz/bla
bar/baz/bla/some.txt
bar/yetanother.txt
other.txt
This MSYS_NO_PATHCONV=1 fix only works on Git Bash.
When comes to msys2, we should use MSYS2_ARG_CONV_EXCL=--path-separator=
Ref: https://www.msys2.org/wiki/Porting/#filesystem-namespaces
Given that we introduced the --path-separator=… option for situations like Cygwin/MSYS2/Git Bash on Windows, it seems really unfortunate users have to go through this experience described in this ticket.
Maybe we should introduce a --path-separator-slash or --unix-path-separator option as an alias for --path-separator="/", which would not require any environment variables to be set?
What do you think?
Good idea!
Okay, let's turn this into a feature request.
I ran into this today trying to use fd on msys2, and just learned about MSYS2_ARG_CONV_EXCL so maybe I can fix my shell alias.
Could fd go a step further and try to auto-detect the path separator at runtime?
MSYSTEM environment variable, which could be checked cheaply/cygdrive/ in PATH (usually PATH contains /cygdrive/c/Windows/System32, among other native windows path entries)C:\foo\bar;C:\baz\quux at runtime, so that won't work.uname process would be too expensive@aswild Great idea. Maybe this could help for cygwin: https://stackoverflow.com/a/3104453 ?
Ooh, OSTYPE looks so promising but apparently it's only set as a shell variable and isn't exported to the environment, foiled again.
It would be great if someone could summarize the current status and what should/could be done here to improve the situation.
I haven't used msys2 for a while. Instead, I'm using WSL now and no longer need this option.
I think it's OK to leave it unchanged since I already give the workaround in msys2 at https://github.com/sharkdp/fd/issues/537#issuecomment-636422669
Most helpful comment
Thank you, that was a great hint, @sharkdp! I am very grateful to you for taking the time to dig into this.
For the record, one needs to set the environment variable
MSYS_NO_PATHCONV=1: