问题描述
我是 Ruby on Rails 的新手.当我运行 rails db:create
时,在 M1 MBP 上运行时出现以下错误:
Hi I am new to Ruby on Rails. When I run rails db:create
, I got the following error when I run it on M1 MBP:
/Library/Ruby/Gems/2.6.0/gems/msgpack-1.4.2/lib/msgpack.rb:8: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)
我的ruby版本是ruby 2.6.3p62(2019-04-16 修订版67580)[universal.arm64e-darwin20]
感谢任何帮助!
推荐答案
我在使用 M1 设备预装的 ruby-2.6.3 时也遇到了这个问题.
I came across this issue as well using the ruby-2.6.3 that comes preinstalled with my M1 device.
我的解决方案是将 ruby 版本更改为其他版本,因为这可能是 Apple 预装的 ruby 版本的问题.例如,我使用 rbenv(管理 ruby 版本的推荐方法)将我的更改为 2.7.3:
My solution was changing the ruby version to something else because this is likely an issue with apple's preinstalled version of ruby.For example, I changed mine to 2.7.3 using rbenv (the recommended way to manage ruby versions):
rbenv install 2.7.3
使用以下方法全局更改 ruby 版本:
Change ruby version globally using:
rbenv global 2.7.3
您可能还需要重新启动终端或执行其他操作以确保正在使用新的 ruby 版本.
You may also need to relaunch your terminal or do other things to ensure that the new ruby version is being used.
这篇关于M1 MBP Rails db:create 为 msgpack 抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!