matchai / spacefish

🚀🐟 The fish shell prompt for astronauts
https://spacefish.matchai.dev
MIT License
963 stars 79 forks source link

Windows MSYS2: -uThe system cannot find the file specified. #117

Closed gertcuykens closed 5 years ago

gertcuykens commented 5 years ago

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

image

matchai commented 5 years ago

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

gertcuykens commented 5 years ago

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

matchai commented 5 years ago

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.

gertcuykens commented 5 years ago

Only in windows Cmd / Powershell and VsCode as far as I can tell unless the error line get ommited as a empty line in msys2 terminal

Note that msys2 has a more uptodate fish version, cygwin still has the old beta version if I look at the version number of the package.

image

image

image

Snuggle commented 5 years ago

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?

gertcuykens commented 5 years ago

both use the same msys2 installed fish version

image

gertcuykens commented 5 years ago

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

gertcuykens commented 5 years ago

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

gertcuykens commented 5 years ago

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)
matchai commented 5 years ago

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?

gertcuykens commented 5 years ago

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?

matchai commented 5 years ago

$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.

image

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.

gertcuykens commented 5 years ago

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 commented 5 years ago

Interesting. Doing the same thing in reverse and uninstalling GNU coreutils on my cherrypie, brings up an error with a similar line. image

Snuggle commented 5 years ago

What version of sort is even being used? Even when using BusyBox's sort, there's a -u flag. image

matchai commented 5 years ago

@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.

matchai commented 5 years ago

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.

Snuggle commented 5 years ago

@matchai Just to purge the use of cut from the entire repository, could I please ask you to replace it here too?https://github.com/matchai/spacefish/blob/42f27c54ba3eefeb6fa7d12289296be5306d7416/scripts/version.fish#L4 https://github.com/matchai/spacefish/blob/42f27c54ba3eefeb6fa7d12289296be5306d7416/functions/__sf_section_git_status.fish#L35

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!"