3

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?

Sami
  • 131
  • 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 Dec 19 '21 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 Dec 19 '21 at 19:30
  • 1
    You still need to get a newer version then, the one you have seems to be only for Intel. – nohillside Dec 19 '21 at 19:31
  • @nohillside Do you have any clue how to do so? – Sami Dec 19 '21 at 19:33
  • https://apple.stackexchange.com/questions/321858/xcrun-missing-installing-xcode-command-line-tools-not-fixing-issue might help – nohillside Dec 19 '21 at 20:16
  • Try this to reinstall the CLT (which will hopefully get you the right architecture. https://trac.macports.org/wiki/ProblemHotlist#reinstall-clt – Marc Wilson Dec 19 '21 at 23:52
  • @nohillside You are right.. it really did help thanks – Sami Dec 20 '21 at 14:11
  • @MarcWilson: MacPorts' documentation is very good! – Seamus Dec 20 '21 at 18:30
  • Did the OP do it and did it install the right version? – Marc Wilson Dec 20 '21 at 23:27
  • uninstall the command line tools and reinstall them: https://apple.stackexchange.com/a/436612/72191 – Charlie Parker Feb 07 '22 at 23:29

1 Answers1

2

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.

Seamus
  • 4,547