Trouble installing gem on M1 arm64-darwin20 mac
jonathanpberger opened this issue · 14 comments
Hello! I'm having trouble running gem install
on an M1 mac.
Has anyone had a similar issue? And, ideally, solved it? :-)
Here's the error
$gem install llhttp-ffi
Building native extensions. This could take a while...
ERROR: Error installing llhttp-ffi:
ERROR: Failed to build gem native extension.
current directory: /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/llhttp-ffi-0.3.0/ext
/Users/jpb/.asdf/installs/ruby/2.7.3/bin/ruby -I/Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/2.7.0/rubygems -rrubygems /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/llhttp-ffi-0.3.0 RUBYLIBDIR\=/Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/llhttp-ffi-0.3.0
rake aborted!
LoadError: dlopen(/Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/ffi-1.15.1/lib/ffi_c.bundle, 9): no suitable image found. Did find:
/Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/ffi-1.15.1/lib/ffi_c.bundle: mach-o, but wrong architecture
/Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/ffi-1.15.1/lib/ffi_c.bundle: mach-o, but wrong architecture - /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/ffi-1.15.1/lib/ffi_c.bundle
Caused by:
LoadError: cannot load such file -- 2.7/ffi_c
Caused by:
LoadError: cannot load such file -- ffi-compiler/compile_task
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/gems/llhttp-ffi-0.3.0 for inspection.
Results logged to /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/llhttp-ffi-0.3.0/gem_make.out
~/workspace/rcrdshp master *2 !5 ?2
and here's the environment
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.6
- RUBY VERSION: 2.7.3 (2021-04-05 patchlevel 183) [arm64-darwin20]
- INSTALLATION DIRECTORY: /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/jpb/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/jpb/.asdf/installs/ruby/2.7.3/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /Users/jpb/.asdf/installs/ruby/2.7.3/bin
- SPEC CACHE DIRECTORY: /Users/jpb/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/jpb/.asdf/installs/ruby/2.7.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- arm64-darwin-20
- GEM PATHS:
- /Users/jpb/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0
- /Users/jpb/.gem/ruby/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/jpb/.asdf/installs/ruby/2.7.3/bin
- /Users/jpb/.asdf/shims
- /opt/homebrew/opt/asdf/bin
- /opt/homebrew/bin
- /opt/homebrew/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Library/Apple/usr/bin
- /opt/homebrew/bin
- /opt/homebrew/sbin
I've tried to reproduce this on my M1 test machine, but no luck so far. I did find this somewhat related article:
It does look like you're using asdf—maybe it's an issue there? Have you tried reinstalling the ffi
gem?
@jonathanpberger Closing this for now. Please feel free to reopen if you have ongoing issues.
Yes, it's weird.
@Amstrong Have you tried reinstalling the ffi
gem as I suggested here? #20 (comment)
Awesome, thanks for the followup @jonathanpberger!
Yes, Rosetta was the solution for me too! thanks @jonathanpberger @bryanp
@rstammer It looks like the ffi
gem (which llhttp-ffi
depends on) is compiled for the wrong architecture. Have you tried reinstalling ffi
? That has fixed this for other folks.
@bryanp Thanks for your kind help. Yes, I've reinstalled it right before - so it should be compiled for the right architecture :-/
@bryanp Finally 🎉 What helped me in the end was removing Ruby again and re-compiling it with the correct architecture, afterwards installing ffi
and llhttp-ffi
again - this worked, so I think the problem may have been that I accidentally compiled Ruby with Rosetta turned on. Thanks!