4

I bought a new MacBook Air with the new M1 chip and I migrated my data from my previous intel mac to this. Now when I try to run git I get the following error:

xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).

When I run it using arch -x86_64 git --version it works and gives the following:

arch -x86_64 git --version                     
git version 2.24.3 (Apple Git-128)

Is there any solution to this so I can run git alone in the terminal without having to specify the architecture first?

10
  • Did you updated to the latest version of Monterey and reinstall Xcode and the command line tools on the new Mac? I get git version 2.32.0 (Apple Git-132) here.
    – nohillside
    Commented Dec 19, 2021 at 19:19
  • @nohillside I don't use Xcode so I don't install it and when I try to install the command line tools manually via xcode-select --install I get the following: xcode-select: error: command line tools are already installed, use "Software Update" to install updates
    – Sami
    Commented Dec 19, 2021 at 19:30
  • 1
    You still need to get a newer version then, the one you have seems to be only for Intel.
    – nohillside
    Commented Dec 19, 2021 at 19:31
  • @nohillside Do you have any clue how to do so?
    – Sami
    Commented Dec 19, 2021 at 19:33
  • apple.stackexchange.com/questions/321858/… might help
    – nohillside
    Commented Dec 19, 2021 at 20:16

1 Answer 1

3

Clearly the best answer is to get the version of git that works with your machine's M1 architecture. That appears to be installation of the Xcode CLT. MacPorts and Homebrew both require CLT, so I don't believe there's a way around that.

However, as an ad-hoc solution, you could create an alias for your shell that would allow you to run the X86 arch version of git. It's a slightly different process for zsh vs. bash, but details for setting up aliases for both are covered in this article.

2

Not the answer you're looking for? Browse other questions tagged .