I am trying to install Truffle on my mac M1.
I started by following the instructions on the truffle web site in the Pet Shop tutorial I got node installed node successfully, but then I get this error...
sudo npm install -g truffle
...
npm ERR! 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)).
I did a bit of research and was pointed at trying it in homebrew instead. I had to update homebrew first because of my M1 chip, which I did successfully. But I still get what appears to be the same or similar error...
/opt/homebrew/bin/brew install truffle
...
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)).
truffle: The x86_64 architecture is required for this software.
I can't find out much about this online.
Does this mean that truffle only runs on intel chips and I need to use something like rosetta?
OK, so I finally figured this out and thought I would post here for posterity.
The issue was the version of the xcode command line tools that I had installed on my M1 Mac. I have no idea how, but it was an out of date version. The fix was to remove the command line tools and reinstall them. I think (I cannot say for certain) that this replaced them with M1/Arm versions and then the compile tools needed were in place.
To update I followed the steps in this Apple Developer Forum post https://developer.apple.com/forums/thread/694283
Basically...
junk the existing folder
sudo rm -rf /Library/Developer/CommandLineTools
re-install
sudo Xcode-select --install
After doing this I re-ran
sudo npm install -g truffle
and it completed successfully (albeit with a bunch of audit warnings)