My fish is blind? (fish does not recognise any commands after setting it as default shell on Mac OS Big Sur, M1 Mac)
Asked Answered
W

2

65

I installed fish with homebrew on Mac OS Big Sur, Apple Silicon. Then I added /opt/homebrew/bin/fish to /etc/shells. When I now start fish from the default shell, it recognises all commands (like git flow init). After changing the default shell with chsh -s /opt/homebrew/bin/fish, suddenly it won't recognise anything anymore and always gives a Unknown command. I haven't found anything regarding this issue and uninstalled fish and brew several times...

Whitby answered 20/3, 2021 at 16:36 Comment(4)
Is PATH set? ..Corrigan
Thanks for the hint! Had to add fish_add_path /opt/homebrew/bin to config.fishWhitby
@Whitby Your comment has also helped me (and possibly others). Would you mind posting it as the accepted answer?Moonwort
Clever title :) It would be good to accept the answer, it worksDiagnostic
P
125

Here are the steps I used to setup the fish shell on my M1 MacBook Air. Per the comments on the question, the key to solving the Unknown Command issue is the fish_add_path:

$ brew install fish ​
$ fish
$ fish_add_path /opt/homebrew/bin
$ echo "/opt/homebrew/bin/fish" | sudo tee -a /etc/shells
$ chsh -s /opt/homebrew/bin/fish

Paternalism answered 2/12, 2021 at 16:48 Comment(3)
Typo in the shell path. Should say echo "/opt/homebrew/bin/fish" on line 4Milurd
@Milurd Oh, yes, you are right. Thank you for your pointing out! I edited.Paternalism
this worked for me, specifically the fish_add_pathKennet
R
0

Hyomin's answer didn't work for me, so here's the workaround I resorted to (it's ugly but it works):

  1. Using Fish as default, open a terminal and write down the executables that don't work e.g. my_command_1
  2. Revert the default shell to your previous one (e.g. zsh), then restart terminal
  3. For each command identified at step 1 (e.g. my_command_1), run which my_command_1. It will output e.g. /some/path/to/my_command_1, then you should run fish_add_path /some/path/to
  4. Set Fish as default shell again and restart terminal. Voilà!

Notes:

  • fish_add_path can be run a single time, future Fish sessions will remember the added paths. But if you prefer, you can also add this command to your ~/.config/fish/config.fish file, as stated in the docs.
  • This solution is obviously based on trial and error: you check what doesn't work, you fix it, but maybe later you find some other things that don't work and you fix those, etc. It's far from perfect, but it's the best I could come up with so far.
Reproductive answered 21/2 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.