Skip to content
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

Git not working with fish + MacOS 12.4 #9052

Closed
jenklu-copia opened this issue Jul 1, 2022 · 4 comments
Closed

Git not working with fish + MacOS 12.4 #9052

jenklu-copia opened this issue Jul 1, 2022 · 4 comments
Labels
macos macOS-specific issue

Comments

@jenklu-copia
Copy link

Please tell us which fish version you are using by executing the following:

🍏 fish --version
fish, version 3.5.0

Please tell us which operating system and terminal you are using. The output of uname -a and echo $TERM may be helpful in this regard although other commands might be relevant in your specific situation.

lucasjenkins@lucas-mbp ~/c/device-agent 🍏 uname -a
Darwin lucas-mbp.lan 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp ~/c/device-agent 🍏 echo $TERM
xterm-256color
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86

Please tell us if you tried fish without third-party customizations by executing this command and whether it affected the behavior you are reporting:

lucasjenkins@lucas-mbp ~/c/device-agent 🍏 sh -c 'env HOME=$(mktemp -d) fish'
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp /U/l/c/device-agent 🍏 git sexec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp /U/l/c/device-agent 🍏 git status
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86

No, this did not affect the behavior I am reporting

Tell us how to reproduce the problem.

I recently obtained a new M1 MacBook Pro

  Model Name:	MacBook Pro
  Model Identifier:	MacBookPro18,1
  Chip:	Apple M1 Pro
  Total Number of Cores:	10 (8 performance and 2 efficiency)
  Memory:	16 GB
  System Firmware Version:	7459.121.3
  OS Loader Version:	7459.121.3

In the process of setting up my dev environment, I set up HomeBrew, downloaded fish and set it as my default shell, and updated my MacOS to Monterey (12.4). After updating, I noticed that for every command I ran, I got a

exec: Failed to execute process '/usr/local/bin/git', unknown error number 86

line after the command output. I suspected the fish_prompt function was the issue, and after digging in, it became clear that the fish_git_prompt was the thing trying to execute git at every prompt. More concerningly, trying to just git from the prompt displayed the same error.

I'm hesitant to even file this bug against fish, but I only do so because I'm not seeing the same problems with the default zsh install on the Macbook, per the following shell transactions:

lucasjenkins@lucas-mbp ~ 🍏 ls
Applications/ Desktop/      Documents/    Downloads/    Library/      Movies/       Music/        Pictures/     Public/       code/
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp ~ 🍏 git
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp ~ [126] 🍏 echo $PATH
/opt/homebrew/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/munki
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp ~ 🍏 which git
/usr/local/bin/git
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp ~ 🍏 zsh
Restored session: Fri Jul  1 19:32:44 EDT 2022
lucasjenkins@lucas-mbp ~ % ls
Applications	Desktop		Documents	Downloads	Library		Movies		Music		Pictures	Public		code
lucasjenkins@lucas-mbp ~ % git
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

<...some git usage output omitted, but it's clear that the git executable works>

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
lucasjenkins@lucas-mbp ~ % echo $PATH
/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki
lucasjenkins@lucas-mbp ~ % which git
/usr/local/bin/git
lucasjenkins@lucas-mbp ~ % 

Saving session...
...saving history...truncating history files...
...completed.
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86
lucasjenkins@lucas-mbp ~ 🍏 
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86

If you need anything else from me please ask, or if you feel confident this is not a fish issue I won't be offended if you close out.

@zanchey
Copy link
Member

zanchey commented Jul 2, 2022

Error 86 appears to be an architecture mismatch (bad CPU type in executable), but I'm not sure what the story with zsh vs fish is in this regard. What does file (command -s git) (command -s fish) (command -s zsh) say?

@zanchey zanchey added the macos macOS-specific issue label Jul 2, 2022
faho added a commit that referenced this issue Jul 2, 2022
That's apparently errno 86 on macOS, and it's triggered when the
architecture is wrong.

I'll leave other macOS errors to the macOS users.

See #9052.
@jenklu-copia
Copy link
Author

jenklu-copia commented Jul 2, 2022

Hrm:

lucasjenkins@lucas-mbp ~/Downloads 🍏 file (command -s git) (command -s fish) (command -s zsh)
/usr/local/bin/git:     Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64Mach-O 64-bit executable x86_64] [i386]
/usr/local/bin/git (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/local/bin/git (for architecture i386):	Mach-O executable i386
/opt/homebrew/bin/fish: Mach-O 64-bit executable arm64
/bin/zsh:               Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64
- Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e
- Mach-O 64-bit executable arm64e]
/bin/zsh (for architecture x86_64):	Mach-O 64-bit executable x86_64
/bin/zsh (for architecture arm64e):	Mach-O 64-bit executable arm64e
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86

(and for good measure)

lucasjenkins@lucas-mbp ~/Downloads 🍏 zsh
Restored session: Sat Jul  2 16:17:39 EDT 2022
lucasjenkins@lucas-mbp Downloads % file `which git` `which fish` `which zsh`
/usr/local/bin/git:     Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64Mach-O 64-bit executable x86_64] [i386]
/usr/local/bin/git (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/local/bin/git (for architecture i386):	Mach-O executable i386
/opt/homebrew/bin/fish: Mach-O 64-bit executable arm64
/bin/zsh:               Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64
- Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e
- Mach-O 64-bit executable arm64e]
/bin/zsh (for architecture x86_64):	Mach-O 64-bit executable x86_64
/bin/zsh (for architecture arm64e):	Mach-O 64-bit executable arm64e

Without a great understanding of the difference between supported file types on Apple Silicon vs. Intel Macs, a bit of googling indicates that arm64 is the native file format for Apple Silicon. Maybe it's possible that zsh (or perhaps some configuration of zsh on Apple Silicon MacOS) is doing some magic to invoke Rosetta "under the hood" when it recognizes an x86_64 executable that isn't replicated in fish?

Edit: Also, thank you so much for the quick response and corresponding CL! Both are greatly appreciated😀

@zanchey
Copy link
Member

zanchey commented Jul 3, 2022

Maybe it's possible that zsh (or perhaps some configuration of zsh on Apple Silicon MacOS) is doing some magic to invoke Rosetta "under the hood" when it recognizes an x86_64 executable that isn't replicated in fish

That does not seem likely to me, but who knows.

Can I ask what terminal you are using, and how your prompt is set up? I am a bit suspicious that running fish with sh -c 'env HOME=$(mktemp -d) fish' still seems to have displayed your custom prompt.

@jenklu-copia
Copy link
Author

I'm just using the standard MacOS terminal Version 2.12.7 (445), here's the output of functions fish_prompt:

🍏 functions fish_prompt
# Defined in /opt/homebrew/Cellar/fish/3.5.0/share/fish/functions/fish_prompt.fish @ line 4
function fish_prompt --description 'Write out the prompt'
    set -l last_pipestatus $pipestatus
    set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
    set -l normal (set_color normal)
    set -l suffix ' 🍏'
    set -q fish_color_status
    or set -g fish_color_status --background=red white

    # Color the prompt differently when we're root
    set -l color_cwd $fish_color_cwd
    if functions -q fish_is_root_user; and fish_is_root_user
        if set -q fish_color_cwd_root
            set color_cwd $fish_color_cwd_root
        end
    end

    # Write pipestatus
    # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it.
    set -l bold_flag --bold
    set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation
    if test $__fish_prompt_status_generation = $status_generation
        set bold_flag
    end
    set __fish_prompt_status_generation $status_generation
    set -l status_color (set_color $fish_color_status)
    set -l statusb_color (set_color $bold_flag $fish_color_status)
    set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)

    echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " "
end
exec: Failed to execute process '/usr/local/bin/git', unknown error number 86

I did some more research online, and supposedly $ arch -x86_64 (which git) should've invoked Rosetta on git and run it from fish. However, I was still seeing arch: posix_spawnp: /usr/local/bin/git: Bad CPU type in executable error messages. After googling that error message, per this StackExchange post, apparently Rosetta doesn't come preinstalled on these M1 Macs. After running softwareupdate --install-rosetta, git and my fish prompt now WAI.

I still don't understand how zsh was running this executable without me ever installing Rosetta; perhaps there's a "system" Rosetta install that only "system" applications (which maybe zsh falls under?) have access to, and as a user-installed shell fish could only access the user-installed Rosetta? I don't fully understand, and I'm not sure there's any action the fish team needs to take here - mayyybe if you're already doing OS+architecture detection, you could have an error message along the lines of I see you're using Apple Silicon, and you received an "archtecture not supported" error. Are you sure you have Rosetta installed?. But even that might be outside the purview of the shell. Closing this out for now given that my issue's resolved, but feel free to reopen if you want to follow up on this somehow.

zanchey pushed a commit that referenced this issue Jul 14, 2022
That's apparently errno 86 on macOS, and it's triggered when the
architecture is wrong.

I'll leave other macOS errors to the macOS users.

See #9052.

(cherry picked from commit 60f87ef)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
macos macOS-specific issue
Projects
None yet
Development

No branches or pull requests

2 participants