【问题标题】:IntelliJ Idea using wrong gitIntelliJ Idea 使用了错误的 git
【发布时间】:2023-01-11 12:26:42
【问题描述】:

我无法让 git 使用 IntelliJ IDEA 2022.3.1(终极版)
MacOS Monterey,12.5,芯片:Apple M1 Pro

git 可执行文件的路径:/usr/local/bin/git

IntelliJ Idea 给我错误信息:
Failed to start Git process: Cannot run program "/usr/local/bin/git" (in directory "."): error=86, Bad CPU type in executable

但是我的git安装没问题

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

% 哪个 git
/usr/local/bin/git

有趣的是,我敢打赌 bash 中会出现类似的错误

% 狂欢
$ git --version
bash: /usr/local/bin/git: 可执行文件中错误的 CPU 类型

看起来我安装了两个不同版本的 git,而 Idea 想使用那个坏的。但它是相同的 git,看:

$哪个混帐
/usr/local/bin/git

有人可以移植请问这是怎么回事?

【问题讨论】:

标签: git macos intellij-idea


【解决方案1】:

您正在尝试为错误的架构运行程序,在本例中为 Git。您必须使用为 ARM64 架构编译的版本。

我不知道你是如何安装 Git 的,是否从 Intel Mac 迁移到 Apple Silicon,或者 IntelliJ 安装是否安装了错误的 Git 版本。

  1. 在终端/usr/sbin/softwareupdate --install-rosetta --agree-to-license中安装 Rosetta 2(二进制翻译器)

    重新启动后,检查它是否有效。如果不...

    1. 从你的机器上卸载所有 Git 版本并安装这个自制版本:Git OSX

【讨论】:

    【解决方案2】:

    看来你的 git 是为 Intel CPU 构建的。

    您可以先删除当前的 git 文件或在终端 /usr/sbin/softwareupdate --install-rosetta --agree-to-license 中安装 Rosetta 2(二进制翻译器)并重新启动您的 Mac。

    您还可以通过以下方式之一删除当前的 git 文件并安装 M1 版本的 git:

    Xcode Command Line Tools(推荐方式)

    打开终端并输入以下命令:

    xcode-select --install

    请阅读这篇文章以获取更多信息:

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

    家酿

    如果你还没有安装homebrew,那么:

    $ brew install git

    MacPorts

    如果你还没有安装MacPorts,那么:
    $ sudo port install git

    【讨论】:

      猜你喜欢
      • 2014-04-18
      • 2014-01-24
      • 1970-01-01
      • 2017-08-20
      • 2017-12-24
      • 1970-01-01
      • 2013-09-23
      • 1970-01-01
      相关资源
      最近更新 更多