Skip to content

/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/ext/arm-darwin/libhttp-parser-ext.bundle: mach-o, but wrong architecture #12

Open

Description

@rgaufman

I've created a simple script:

require 'json'
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'http'
end

response = HTTP.post('http://example.com', json: nil)

When I run it on MacBook 2020 M1 (Apple Silicon), I see:

Traceback (most recent call last):
	24: from test-http-arse.rb:8:in `<main>'
	23: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/inline.rb:54:in `gemfile'
	22: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/settings.rb:124:in `temporary'
	21: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/inline.rb:70:in `block in gemfile'
	20: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
	19: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
	18: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
	17: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
	16: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
	15: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/bundler/runtime.rb:74:in `require'
	14: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http.rb:8:in `<top (required)>'
	13: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http.rb:8:in `require'
	12: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http/client.rb:9:in `<top (required)>'
	11: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http/client.rb:9:in `require'
	10: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http/connection.rb:6:in `<top (required)>'
	 9: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http/connection.rb:6:in `require'
	 8: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http/response/parser.rb:3:in `<top (required)>'
	 7: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-4.4.1/lib/http/response/parser.rb:3:in `require'
	 6: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/lib/http-parser.rb:5:in `<top (required)>'
	 5: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/lib/http-parser.rb:5:in `require'
	 4: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/lib/http-parser/ext.rb:6:in `<top (required)>'
	 3: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/lib/http-parser/ext.rb:8:in `<module:HttpParser>'
	 2: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi/library.rb:99:in `ffi_lib'
	 1: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi/library.rb:99:in `map'
/opt/homebrew/lib/ruby/gems/2.7.0/gems/ffi-1.13.1/lib/ffi/library.rb:145:in `block in ffi_lib': Could not open library '/opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/ext/arm-darwin/libhttp-parser-ext.bundle': dlopen(/opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/ext/arm-darwin/libhttp-parser-ext.bundle, 5): no suitable image found.  Did find: (LoadError)
	/opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/ext/arm-darwin/libhttp-parser-ext.bundle: mach-o, but wrong architecture
	/opt/homebrew/lib/ruby/gems/2.7.0/gems/http-parser-1.2.2/ext/arm-darwin/libhttp-parser-ext.bundle: stat() failed with errno=25

Any ideas?

Activity

  1. TheMlok commented on Dec 28, 2020

    @TheMlok

    We have it like a dependency in Rails application, please any solution how to run it on M1?

  2. stevehodgkiss commented on Dec 28, 2020

    @stevehodgkiss

    There's an open PR to address this issue #10

  3. DaniG2k commented on Jan 10, 2021

    @DaniG2k

    I'm having a similar problem on a Rails 5.0.7.2 app. Tried installing http-parser 1.2.2 but I get the same message 🤔 :

    LoadError: Could not open library '/Users/danig2k/.rvm/gems/ruby-2.6.6/gems/http-parser-1.2.2/ext/aarch64-darwin/libhttp-parser-ext.bundle': dlopen(/Users/danig2k/.rvm/gems/ruby-2.6.6/gems/http-parser-1.2.2/ext/aarch64-darwin/libhttp-parser-ext.bundle, 5): no suitable image found.  Did find:
    	/Users/danig2k/.rvm/gems/ruby-2.6.6/gems/http-parser-1.2.2/ext/aarch64-darwin/libhttp-parser-ext.bundle: mach-o, but wrong architecture
    	/Users/danig2k/.rvm/gems/ruby-2.6.6/gems/http-parser-1.2.2/ext/aarch64-darwin/libhttp-parser-ext.bundle: stat() failed with errno=25
    

    I believe the http gem is the one requiring http-parser.

  4. rgaufman commented on Jan 10, 2021

    @rgaufman
    Author

    http-parser is a dependency of httbrb for us. Our solution was to switch to faraday which removed this dependency.

  5. stevenjohn commented on Jan 20, 2021

    @stevenjohn

    Hi there,

    I'm on Apple Silicon and getting the same error as @rgaufman

    Building native extensions. This could take a while...
    ERROR:  Error installing http-parser:
    	ERROR: Failed to build gem native extension.
    
        current directory: /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/http-parser-1.2.3/ext
    /Users/steve/.rbenv/versions/2.6.6/bin/ruby -rrubygems /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-12.3.3/exe/rake RUBYARCHDIR\=/Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/http-parser-1.2.3 RUBYLIBDIR\=/Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/http-parser-1.2.3
    rake aborted!
    LoadError: dlopen(/Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 9): no suitable image found.  Did find:
    	/Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle: mach-o, but wrong architecture
    	/Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle: mach-o, but wrong architecture - /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle
    
    
    Caused by:
    LoadError: cannot load such file -- 2.6/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/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/http-parser-1.2.3 for inspection.
    Results logged to /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/http-parser-1.2.3/gem_make.out
    

    I'm installing v 1.2.3 and I'm confused as it looks like the PR to fix the m1 chip issue was merged?

    Any ideas how I get http-parser to install correctly?

    Many thanks, Steve.

  6. nitrnitr commented on Feb 11, 2021

    @nitrnitr

    Fixing the http-version on the Gemfile did it for me, new version has this fixed

    gem 'http-parser', '~> 1.2.3'

  7. rstammer commented on Sep 18, 2021

    @rstammer

    Unfortunately, for Ruby 2.7.x, I still do face the issue when trying to gem install http-parser -v '1.2.3', so what @nitrnitr described does not apply to my situation so far.

    Here's the error log:

    LoadError: dlopen(/Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi_c.bundle, 9): no suitable image found.  Did find:
    	/Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture
    	/Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture - /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi_c.bundle
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi.rb:5:in `rescue in <top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi.rb:2:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/http-parser-1.2.3/ext/Rakefile:1:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/rake-13.0.6/exe/rake:27:in `<main>'
    
    Caused by:
    LoadError: cannot load such file -- 2.7/ffi_c
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-1.15.4/lib/ffi.rb:3:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/http-parser-1.2.3/ext/Rakefile:1:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/rake-13.0.6/exe/rake:27:in `<main>'
    
    Caused by:
    LoadError: cannot load such file -- ffi-compiler/compile_task
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/http-parser-1.2.3/ext/Rakefile:1:in `<top (required)>'
    /Users/robinstammer/.rvm/gems/ruby-2.7.4/gems/rake-13.0.6/exe/rake:27:in `<main>'
    (See full trace by running task with --trace)
    
    rake failed, exit code 1
    

    Any ideas?

  8. ryanstuhl805 commented on Nov 19, 2021

    @ryanstuhl805

    Similar output happening with a non M1 machine recently updated to Mac OS Monterey.

    Installing llhttp-ffi 0.4.0 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
        current directory: /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/llhttp-ffi-0.4.0/ext
    /Users/snip/.rbenv/versions/2.7.4/bin/ruby -I/Users/snip/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems -rrubygems /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake
    RUBYARCHDIR\=/Users/snip/Git/admin/.bundle/ruby/2.7.0/extensions/x86_64-darwin-20/2.7.0/llhttp-ffi-0.4.0 RUBYLIBDIR\=/Users/snip/Git/admin/.bundle/ruby/2.7.0/extensions/x86_64-darwin-20/2.7.0/llhttp-ffi-0.4.0
    rake aborted!
    LoadError: incompatible library version - /Users/snip/Git/admin/.bundle/ruby/2.7.0/extensions/x86_64-darwin-20/2.7.0/ffi-1.15.4/ffi_c.bundle
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/ffi-1.15.4/lib/ffi.rb:5:in `rescue in <top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/ffi-1.15.4/lib/ffi.rb:2:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/llhttp-ffi-0.4.0/ext/Rakefile:3:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<main>'
    
    Caused by:
    LoadError: cannot load such file -- 2.7/ffi_c
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/ffi-1.15.4/lib/ffi.rb:3:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/ffi-compiler-1.0.1/lib/ffi-compiler/compile_task.rb:4:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/llhttp-ffi-0.4.0/ext/Rakefile:3:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<main>'
    
    Caused by:
    LoadError: cannot load such file -- ffi-compiler/compile_task
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/llhttp-ffi-0.4.0/ext/Rakefile:3:in `<top (required)>'
    /Users/snip/Git/admin/.bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake:27:in `<main>'
    (See full trace by running task with --trace)
    
    An error occurred while installing llhttp-ffi (0.4.0), and Bundler cannot continue.
    
    In Gemfile:
      noticed was resolved to 1.5.3, which depends on
        http was resolved to 5.0.4, which depends on
          llhttp-ffi
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions