Home > Enterprise >  IntelliJ Idea using wrong git
IntelliJ Idea using wrong git

Time:01-11

I'm unable to get git working with IntelliJ IDEA 2022.3.1 (Ultimate Edition)
MacOS Monterey, 12.5, Chip: Apple M1 Pro

Path to git executable: /usr/local/bin/git

And IntelliJ Idea gives me error message:
Failed to start Git process: Cannot run program "/usr/local/bin/git" (in directory "."): error=86, Bad CPU type in executable

But my git installation is OK

% git --version
git version 2.37.1 (Apple Git-137.1)

% which git
/usr/local/bin/git

Interesting is, that I'll bet similar error in bash

% bash
$ git --version
bash: /usr/local/bin/git: Bad CPU type in executable

It looks like I have two different versions of git installed, and Idea wants to use the bad one. But it is the same git, look:

$ which git
/usr/local/bin/git

Could someone explant pls what is going on?

CodePudding user response:

You’re trying to run a program for the wrong architecture, which in this case is Git. You have to use a version compiled for ARM64 architecture.

I don't know how you installed your Git, if you migrated from an Intel Mac to Apple Silicon, or if the IntelliJ installation installed the wrong Git version.

  1. Install Rosetta 2 (Binary translator), in terminal /usr/sbin/softwareupdate --install-rosetta --agree-to-license

After reboot, check if it works. If not...

  1. Uninstall all Git versions from your machine and install this homebrew version: Git OSX

CodePudding user response:

It seems that your git is built for Intel CPU.

You can first remove the current git files or install Rosetta 2 (Binary translator), in terminal /usr/sbin/softwareupdate --install-rosetta --agree-to-license and reboot your Mac.

And you can also remove the current git files and install an M1 version git in one of the following ways:

Xcode Command Line Tools(The recommended way)

Bring up a terminal and input this command:

xcode-select --install

Please read this article for more information:

https://mac.install.guide/commandlinetools/4.html

Homebrew

Install homebrew if you don't already have it, then:

$ brew install git

MacPorts

Install MacPorts if you don't already have it, then:
$ sudo port install git

  • Related