【问题标题】:Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5您的 Ruby 版本是 2.6.8,但您的 Gemfile 指定了 2.7.5
【发布时间】:2022-11-08 03:59:55
【问题描述】:

我已经在 macOS 和 npm 版本中安装了 node@16(v16.18.0):8.19.2

  • 操作系统 macOS(Monterey) 版本:12.6
  • Xcode 版本:14.0.1

按照一些说明在我的设备中使用以下步骤设置 react-native 环境:

  1. 自制安装(版本:3.6.7): /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. 守望者安装(版本:2022.10.24.00):brew install watchman
  3. 安装 Ruby(版本:2.6.8p205):brew install ruby
  4. 安装 CocoaPods(宝石版本:3.0.3.1): sudo gem install cocoapods
  5. 固定位置的 CocoaPods(吊舱版本:1.11.3): sudo gem install -n /usr/local/bin ffi cocoapods

    成功安装上述所有内容后,我将使用npx react-native init AwesomeProject 命令创建 react-native 应用程序并面临Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5 错误也在附件中给出。请检查它并帮助我提出解决方法。

    下面提到了所有资源,我遵循这些资源来解决这个问题,但我没有解决它。

    1. How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting
    2. Your Ruby version is 2.5.1 but your Gemfile specified 2.4.0
    3. rbenv Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2

【问题讨论】:

  • 那么第3步是你的问题。您显然安装了 2.6.8,但您的 gemfile 需要 2.7.5。所以安装 2.7.5 或更改 Gemfile。

标签: javascript ios ruby react-native gemfile


【解决方案1】:

您需要安装正确的 Ruby 版本。如果您为此使用一些 ruby​​ 版本管理器,那将是最好的。例如rbenv

您可以尝试使用这些命令来安装全局 Ruby 版本并将其更改为 2.7.5

$ brew update
$ brew install ruby-build
$ brew install rbenv

$ rbenv install 2.7.5
$ rbenv global 2.7.5

【讨论】:

  • 非常感谢@Alexander,我试过了,但我遇到了另一个问题,比如 Homebrew 没有基于 Gemfile 配置。确实,有些用户可以按照上述命令解决它。
  • 你能描述一下那个问题吗?你运行什么命令,错误的输出是什么?
【解决方案2】:

正如 Alexander 所说,使用 rbenvrvm 来管理您的 ruby​​ 版本。 MacOS 会自动带来原生版本的 ruby​​。您应该避免更新或更改您的本机 (MacOS) ruby​​ 版本。

更多信息为什么不使用系统 ruby​​ 以及常见问题:https://mac.install.guide/faq/do-not-use-mac-system-ruby/index.html

【讨论】:

  • 我已经被版本管理器尝试为 rbenv 并且它解决了,然后我遇到了 Homebrew 不匹配的另一个问题。
【解决方案3】:

我对这些确切的版本有同样的问题。这是我的解决方案:Fix Your Ruby version is 2.6.8, but your gemfile specified 2.5.5

【讨论】:

    猜你喜欢
    • 2016-03-04
    • 2014-05-27
    • 2018-06-09
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多