首页 > 解决方案 > 我该如何修复这个 MacOS(m1) Ruby Mess

问题描述

MacOS 新手,尝试安装 ruby​​ 并愚蠢地使用 sudo,最终在我的 ruby​​ 2.6 系统版本中使用了 Gems。

我尝试使用 brew 来更正此问题以安装新版本的 ruby​​,但是当我使用“rails new appname”时,gems 仍安装在系统目录中

红宝石-v

ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]

哪个 Ruby 返回以下内容(对我来说看起来不正确)

/opt/homebrew/opt/ruby/bin/ruby

如果我运行 rails new app 我会得到以下信息

        Using rake 13.0.6
    Following files may not be writable, so sudo is needed:
      /Library/Ruby/Gems/2.6.0
      /Library/Ruby/Gems/2.6.0/build_info
      /Library/Ruby/Gems/2.6.0/build_info/nokogiri-1.12.2-x86_64-darwin.info
      /Library/Ruby/Gems/2.6.0/cache
      /Library/Ruby/Gems/2.6.0/doc
      /Library/Ruby/Gems/2.6.0/extensions
      /Library/Ruby/Gems/2.6.0/gems
      /Library/Ruby/Gems/2.6.0/specifications
      /usr/local/bin
.....
.....
Bundle complete! 17 Gemfile dependencies, 73 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  bundle binstubs bundler
       rails  webpacker:install
rails aborted!
LoadError: dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle, 0x0009): could not use '/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle' because it is not a compatible arch - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.3/lib/ffi_c.bundle

我的路径如下

/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin

关于如何让这个工作的任何想法,到目前为止我能找到的所有文档都没有帮助。

标签: ruby-on-railsrubymacosapple-m1

解决方案


推荐阅读