Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to install ruby 3.1.0 on M1 - library not found for -lcapstone

Tags:

ruby

apple-m1

linking shared-library libruby.3.1.dylib ld: library not found for -lcapstone clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libruby.3.1.dylib] Error 1

like image 530
ManjunathaThimmaiah Avatar asked Oct 26 '25 10:10

ManjunathaThimmaiah


1 Answers

As explained in Failed to install ruby 3.1.0 on M1 · Discussion #1933 · rbenv/ruby-build, two approaches are possible:

  1. Instruct the environment of where to look for the not-found libraries:
# Assuming Fish-shell, and that the two following directories are indeed present
# Adapting to Bourne affine shells is left as an exercise 😄
set -gx LDFLAGS "-L/opt/homebrew/opt/capstone/lib"
set -gx CPPFLAGS "-I/opt/homebrew/opt/capstone/include"

# relaunch the install process with installation manager
# rbenv install 3.1.0
# asdf install ruby 3.1.0
  1. remove optional dependencies, capstone being "[used] in YJIT but only when cppflags="-DRUBY_DEBUG" is specified":
brew uninstall bloaty
brew uninstall capstone

# Adapt to fit local environment:
set -gx RUBY_CFLAGS "-w"
rbenv install 3.1.0
# asdf install ruby 3.1.0

And run the installation again by providing:

like image 68
ManjunathaThimmaiah Avatar answered Oct 28 '25 04:10

ManjunathaThimmaiah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!