【问题标题】:rbenv - Ruby - How to switch ruby versions between multiple projectsrbenv - Ruby - 如何在多个项目之间切换 ruby​​ 版本
【发布时间】:2021-12-31 08:17:16
【问题描述】:

我使用 rbenv 安装了 Ruby。我正在使用 Mac。对于我的一个项目,我使用的是 ruby​​ 2.6.3。对于我的另一个项目,我需要 ruby​​ 2.7.4。所以我安装了这两个版本。

在我的第一个项目中,如果我使用 rbenv 版本,它会正确显示

   system
   * 2.6.3 (set by /Users/suganyas/academics/project1/.ruby-version)
    2.7.4

对于我的第二个项目,我使用命令设置 ruby​​ 版本 2.7.4

rbenv local 2.7.4

因此,如果我从第二个项目中执行 rbenv 版本,它会再次显示,

  system
  2.6.3
  * 2.7.4 (set by /Users/suganyas/project2/ceep/.ruby-version)

但是当我进行捆绑安装时,我收到以下错误

  Your Ruby version is 2.6.3, but your Gemfile specified 2.7.4

完整的跟踪在这里

    The git source `git://github.com/sqlninja/outdatedbrowser_rails.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
   The git source `git://github.com/nhodges/phantomjs-gem.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
    The git source `git://github.com/heapsource/active_model_otp.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
  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/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
Your Ruby version is 2.6.3, but your Gemfile specified 2.7.4

请帮助我做错了什么。

【问题讨论】:

  • 也许this article 可能会有所帮助。
  • 您是否也为 Ruby 2.7.4 安装了 bundler?切换到 Ruby 2.7.4 然后运行 ​​gem install bundler 可能会有所帮助。
  • @spickermann,是的,也安装了捆绑器。还是同样的问题。

标签: ruby bundler rbenv


【解决方案1】:

运行以下命令帮助我选择了正确的 rbenv 本地版本

echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

【讨论】:

    猜你喜欢
    • 2012-05-14
    • 1970-01-01
    • 2018-06-02
    • 2012-04-24
    • 2012-02-27
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多