the_silver_searcher icon indicating copy to clipboard operation
the_silver_searcher copied to clipboard

Process gets killed on M1 Apple chips

Open Snugug opened this issue 3 years ago • 9 comments

Thanks for such a great tool! It's really integral to my productivity.

Unfortunately, I've installed ag through Homebrew on a new M1 MacBook Pro running OS 11.1. Running under both ZSH and Bash, when I try and run ag, the command is immediately killed without running. If there are debugging steps I can take to get more information for what's causing it to be killed, I'm more than happy to look into it.

Thanks!

Snugug avatar Jan 08 '21 23:01 Snugug

$ brew install the_silver_searcher --HEAD
$ file =ag
/opt/homebrew/bin/ag: Mach-O 64-bit executable arm64

Using ag works fine for me with this.

lewurm avatar Apr 14 '21 10:04 lewurm

Thanks for the comment. While the command you've suggested does work for me when I run it, when trying to actually run ag, this is what I get:

$  ag "Hello"
[1]    68819 killed     ag "Hello"

Snugug avatar Apr 26 '21 10:04 Snugug

What does echo $? print after the command you have posted? And what does

$ file `which ag`

print for you?

lewurm avatar Apr 27 '21 06:04 lewurm

Thanks for the help! Here's the three commands, with their output, back-to-back:

$ ag "Hello"
[1]    1151 killed     ag "Hello"
$ echo $?
137
$ file `which ag`
/opt/homebrew/bin/ag: Mach-O 64-bit executable arm64

This was run in zsh. Running the same in bash, I get the same output, except for ag where I get Killed: 9. macOS Big Sur 11.2.3 on the M1 MacBook Pro, 16GB memory if this helps.

Snugug avatar Apr 27 '21 13:04 Snugug

137 and -9 are the same return code, but zsh interprets it as uint8, while bash interprets it as int8 (I never understood why they do it differently), and it means that the process received SIGKILL. Why the process receives such a signal can have multiple reasons, so meh 😕

However, after googling a bit, my wild guess is that the libpcre you have installed is built for the wrong architecture.

Do you mind to check the output of the following?

otool -L `which ag` | awk '{ print $1 }' | grep pcre | xargs file
/opt/homebrew/opt/pcre/lib/libpcre.1.dylib: Mach-O 64-bit dynamically linked shared library arm64

If your libpcre.dylib isn't for arm64, brew reinstall pcre2 should fix it as suggested in the linked issue.

lewurm avatar Apr 27 '21 17:04 lewurm

Thank you so much for digging in and helping out!

Ok, unfortunately, that didn't resolve the issue. Running the command you shared, the arm64 version was installed. I tried reinstalling it anyway, and reinstalling ag after that, but I'm still getting the same errors.

Snugug avatar Apr 27 '21 21:04 Snugug

What's the output of file for other libs listed by otool (with /opt/homebrew prefix only)?

$ otool -L `which ag` 
/opt/homebrew/bin/ag:
	/opt/homebrew/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.12.0)
	/opt/homebrew/opt/xz/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.5.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
$ file /opt/homebrew/opt/xz/lib/liblzma.5.dylib
/opt/homebrew/opt/xz/lib/liblzma.5.dylib: Mach-O 64-bit dynamically linked shared library arm64

lewurm avatar Apr 30 '21 10:04 lewurm

Again, really appreciate you looking into this! It looks like my output is the same as yours:

$ otool -L `which ag` 
/opt/homebrew/bin/ag:
	/opt/homebrew/opt/pcre/lib/libpcre.1.dylib (compatibility version 4.0.0, current version 4.12.0)
	/opt/homebrew/opt/xz/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.5.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
$ file /opt/homebrew/opt/xz/lib/liblzma.5.dylib
/opt/homebrew/opt/xz/lib/liblzma.5.dylib: Mach-O 64-bit dynamically linked shared library arm64

Snugug avatar Apr 30 '21 13:04 Snugug

Running 'brew reinstall pcre' on my M1 Mac Mini worked. ag is now working thanks.

l1dge avatar May 27 '21 17:05 l1dge