Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing support for Apple Silicon #195

Closed
TonyWu20 opened this issue Nov 21, 2020 · 16 comments
Closed

Missing support for Apple Silicon #195

TonyWu20 opened this issue Nov 21, 2020 · 16 comments

Comments

@TonyWu20
Copy link

Calling msgpack-ruby on Mac with Apple Silicon will show
LoadError: dlopen(/Users/tonywu/Downloads/msgpack-ruby-master/lib/msgpack/msgpack.bundle, 0x0009): missing compatible arch in /Users/tonywu/Downloads/msgpack-ruby-master/lib/msgpack/msgpack.bundle - /Users/tonywu/Downloads/msgpack-ruby-master/lib/msgpack/msgpack.bundle
Since msgpack has supported Apple Silicon, I hope the msgpack-ruby can add support to it soon. Thanks for your great effort!

@tagomoris
Copy link
Member

tagomoris commented Nov 24, 2020

Could you check what will happen when you do the commands below?:

$ uname -a
$ gem i msgpack
$ ruby -e 'p RUBY_VERSION; require "msgpack"`

@TonyWu20
Copy link
Author

Could you check what will happen when you do the commands below?:

$ gem i msgpack
$ ruby -e 'require "msgpack"`

I brew installed the ruby compiled for arm64 architecture, and then I conducted the commands. The output is:

Traceback (most recent call last):
        2: from -e:1:in `<main>'
        1: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- msgpack (LoadError)
        6: from -e:1:in `<main>'
        5: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
        4: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
        3: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `require'
        2: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:9:in `<top (required)>'
        1: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- msgpack/2.7/msgpack (LoadError)
        7: from -e:1:in `<main>'
        6: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
        5: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
        4: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `require'
        3: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:8:in `<top (required)>'
        2: from /opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack.rb:11:in `rescue in <top (required)>'
        1: from /opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/opt/homebrew/Cellar/ruby/2.7.2/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': dlopen(/opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack/msgpack.bundle, 9): no suitable image found.  Did find: (LoadError)
        /opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack/msgpack.bundle: mach-o, but wrong architecture
        /opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack/msgpack.bundle: mach-o, but wrong architecture - /opt/homebrew/lib/ruby/gems/2.7.0/gems/msgpack-1.3.3/lib/msgpack/msgpack.bundle

@tagomoris
Copy link
Member

I guess there is a mismatch between the ruby runtime's architecture (x86/arm64) and the msgpack's binary architecture (this should be determined by the architecture when you run gem install msgpack).

I don't have M1 mac for now, so I cannot identify & fix this problem immediately.

@nobu
Copy link
Contributor

nobu commented Nov 24, 2020

It is caused by rubygems which copies shared objects to the library path w/o the arch name.
The same shared object should exist under /opt/homebrew/lib/ruby/gems/2.7.0/.
If there is the bundle for arm, you will be able to load it by removing the wrong bundle file under /opt/homebrew/lib/ruby/gems/2.7.0/gems/.

@TonyWu20
Copy link
Author

It is caused by rubygems which copies shared objects to the library path w/o the arch name.
The same shared object should exist under /opt/homebrew/lib/ruby/gems/2.7.0/.
If there is the bundle for arm, you will be able to load it by removing the wrong bundle file under /opt/homebrew/lib/ruby/gems/2.7.0/gems/.

This works. Closed with thanks

@messutied
Copy link

Hi @TonyWu20, I'm facing the same issue, can you explain what exactly you did to get this fixed?

@netrabadami
Copy link

Can i know how has it been resolved. i am facing the same issue

ruby -e 'require "msgpack"'
Traceback (most recent call last):
2: from -e:1:in <main>' 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- msgpack (LoadError) 6: from -e:1:in

'
5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in require' 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in rescue in require'
3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in require' 2: from /Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack.rb:8:in <top (required)>'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require': dlopen(/Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle - /Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle (LoadError)

@nobu
Copy link
Contributor

nobu commented Mar 23, 2021

Please read #195 (comment).

@netrabadami
Copy link

netrabadami commented Mar 23, 2021

i did not install ruby using homebrew, hence there is nothing in /opt/homebrew. I ran bundle that installed ruby for me.
Am i missing anything basis out here?

UPDATE: I fixed it by - brew install ruby

@RipeFruit08
Copy link

It is caused by rubygems which copies shared objects to the library path w/o the arch name.
The same shared object should exist under /opt/homebrew/lib/ruby/gems/2.7.0/.
If there is the bundle for arm, you will be able to load it by removing the wrong bundle file under /opt/homebrew/lib/ruby/gems/2.7.0/gems/.

Would this happen if not using Homebrew? I'm experiencing this issue on an M1 Mac but haven't used Homebrew on this machine. Where might this wrong bundle file exist then?

@nobu
Copy link
Contributor

nobu commented Mar 28, 2021

i did not install ruby using homebrew, hence there is nothing in /opt/homebrew. I ran bundle that installed ruby for me.
Am i missing anything basis out here?

You can see the path which caused the problem, in the log which you posted.

1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle - /Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle (LoadError)

/Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack/msgpack.bundle appears three times.

@moudio
Copy link

moudio commented Jul 12, 2021

Hi, can someone make this more clear? I don't understand what solved the issue.

@cmolina
Copy link

cmolina commented Jan 6, 2022

I needed to delete some gems that were targeting a wrong architecture.

These instructions use bundle, but you can adapt them to whatever you use. This worked for me:

  1. Open a new terminal, make sure running arch outputs arm64
  2. Delete your gems. Because I use bundle, I followed this SO answer:
    1. Comment all the lines of your Gemfile
    2. Run bundle clean --force
    3. Revert commenting the lines of your Gemfile
  3. Install your gems. With bundle:
    1. Run bundle install

@JohnOHFS
Copy link

JohnOHFS commented May 2, 2022

@cmolina Thanks. This was the only thing that worked after countless hours trying!

@deb-anjos
Copy link

@cmolina Many thanks! After a day trying this actually solved the problem.

@Dansando8
Copy link

@cmolina Hey, after a day of trial and errors we have solved the same problem! Thx 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests