Windows MSYS2: -uThe system cannot find the file specified.
Closed this issue · 18 comments
After installation trough fisher and installing powerfont fish gives the following error
if not functions -q fisher
set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
curl https://git.io/fisher --create-dirs -sLo $XDG_CONFIG_HOME/fish/functions/fisher.fish
fish -c fisher
end
Environment
- Spacefish version: [the output of
echo $SPACEFISH_VERSION
] - Fish version: [2.7.1]
- Fish plugin manager: fisher
- Terminal emulator: [VSCode]
- Operating system: [Windows 10]
VSCode runs a separate terminal emulator within it, defined in its settings by terminal.external.windowsExec
. Would you be able to provide that for us?
As a side note: to get the powerfont working, you will want to set it in VSCode settings with terminal.integrated.fontFamily
This is my current vscode settings
{
"terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\fish.exe",
"terminal.integrated.env.windows": {
"MSYSTEM": "MSYS"
},
"terminal.integrated.fontSize": 16,
"terminal.integrated.fontFamily":"",
"editor.fontSize": 16,
"git.path": "C:\\git\\bin\\git.exe"
}
Note that i didn't change the following and is still default
"terminal.external.windowsExec": "C:\\WINDOWS\\System32\\cmd.exe"
Further more I use the vanilla msys2 install and use the msys2 package manager to install fish
This seems like it's probably a compatibility issue with msys2. The only Window environment we test in CI is Cygwin, though I don't think it would be difficult to add a run for msys2 as well on Appveyor.
Does this issue happen in a terminal emulator outside of VSCode?
I'll try to get around to installing msys2 on my own machine to do some fishing for this issue and welcome other Windows contributors to try to investigate this issue as well.
Huh. I wonder if this is a file check within a Spacefish function or if this is a Fish issue. What version of Fish does PowerShell and CygWin use?
Could we also experiment a little with debug statements? Let's say an echo right at the start of Spacefish, before any sections get loaded and one right after the entire prompt?
Also if i recall corectly de message only apears after installing spacefish
Anyway trying to scope down where exactly the problem is
This happens when I echo in the frist line and last line in fish_prompt.fish
-uThe system cannot find the file specified.
DEBUG1
gertc in ~/.config/fish
➜ DEBUG2
So it must happen before the prompt script. But I dont know what file runs before the prompt script only have fisher and spacefish installed
Found the needle in the haystack, when I comment out this line I dont have the error message anymore
# set -l trimmed_index (string split \n $index|cut -c 1-2|sort -u)
C:\msys64\home\gertc.config\fish\functions__sf_section_git_status.fish
Also when I execute that line I get the exact same error message
gertc in ~/.config/fish
➜ set -l trimmed_index (string split \n $index|cut -c 1-2|sort -u)
-uThe system cannot find the file specified.
Conclusion /c/Windows/system32/sort doesn't accept stdin
Can we sort it in a other way?
# set -l trimmed_index (string split \n $index|cut -c 1-2|sort -u)
set -l trimmed_index (string split \n $index|cut -c 1-2)
Oh wow! Nice find! 👍
I imagine the issue is due to the -u
flag passed to sort.
I know Cygwin installs most of the usual GNU utilities, which is why this wouldn't have been caught by CI. Does msys2 provide a convenient way to install GNU sort?
Maybe the msys2 coreutils package?
Your right tested set -l trimmed_index (string split \n $index|cut -c 1-2|sort)
and that works also. I will look into the coreutils thing. But is the index already unique in the first place? Don't know
Note that I probably will destroy windows if I tell windows to use the other sort because its a system32 thing?
$index
is not necessarily unique. It is a list of all changes in a git repo, so if you have multiple of the same file diff-types, you might be duplicate git symbols without the -u
.
With regards to replacing sort, you definitely shouldn't do it globally. If your terminal emulator has coreutils installed (as Cygwin has by default), it should only be scoped to terminal instances.
It might be worthwhile testing for which version of sort
is available, and falling back on Windows' argument when necessary.
Coreutils doesn't seem to include it
gertc in ~/.config/fish
➜ pacman -S coreutils
warning: coreutils-8.30-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
Packages (1) coreutils-8.30-1
Total Installed Size: 23.40 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [###############################################] 100%
(1/1) checking package integrity [###############################################] 100%
(1/1) loading package files [###############################################] 100%
(1/1) checking for file conflicts [###############################################] 100%
(1/1) checking available disk space [###############################################] 100%
:: Processing package changes...
(1/1) reinstalling coreutils [###############################################] 100%
gertc in ~/.config/fish took 10s 666ms
➜ which sort
/c/Windows/system32/sort
gertc in ~/.config/fish
➜
➜ pacman -S sort
error: target not found: sort
gertc in ~/.config/fish
Anyway will look for a sort
@Snuggle The error on your screenshot looks like it's with cut
. We should probably replace that with string split
anyway to avoid this sort of issue.
Oh! Thinking it over again, I forgot we changed the implementation of the git status section when porting it over, to make it simpler with string match
and wildcards. I'm fairly certain we don't need sort -u
at all! The duplication shouldn't cause any issues. 😄
I'll try making a PR solving both issues surfaced here.
@matchai Just to purge the use of cut
from the entire repository, could I please ask you to replace it here too?
spacefish/scripts/version.fish
Line 4 in 42f27c5
It sounds like string sub
might be more appropriate for the git status, since it is a substring? Something similar to string sub --start 1 --length 2
.
[Edit] If you need a commit summary idea, perhaps: "Let's cut out cut!"