Rbenv使用的版本不正确 [英] Rbenv not using the correct version

查看:98
本文介绍了Rbenv使用的版本不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的rails项目中,当我尝试运行捆绑安装时,出现以下错误:

In my rails project, when I try to run bundle install, I get the following error:

您的Ruby版本是2.3.7,但是您的Gemfile指定了2.5.3

但是,当我运行 ruby​​ --version 我得到:

However, when I run ruby --version I get:

ruby​​ 2.5.3p105(2018-10-18修订版65156)[x86_64-darwin18]

...并运行 rbenv版本我:

2.5.3(由/Users/jamesmulholland/proj/repo-name/.ruby-version设置)

这是为什么要在此处使用的Ruby版本错误,以及如何解决?

What is cauing this the wrong version of Ruby to be used here, and how do I fix it?


  • 运行 rbenv版本给出:

    系统
    2.5.3(设置由/Users/jamesmulholland/proj/repo-name/.ruby-version)`

从Ruby 2.5.1迁移到Ruby 2.5.3的过程中发生。同时,我从rvm转到rbenv。我怀疑我运行 rm -rf〜/ .rvm 而不是 rvm爆破时可能错误地卸载了rvm,但是 / etc / rbenv / 为空,运行 rvm 命令失败。 rvm 已从我的 .zshrc 中删除​​。当使用这种方法卸载rvm后继续遇到此问题时,我重新安装了rvm,并使用 rvm implode 进程进行了卸载,以防万一还有其他的rvm痕迹。引起问题。

This issue has occurred during a move from Ruby 2.5.1 to Ruby 2.5.3. At the same time, I moved from rvm to rbenv. I suspect I may have uninstalled rvm incorrectly as I ran rm -rf ~/.rvm rather than rvm implode but /etc/rbenv/ is empty and running rvm commands fails. rvm is removed from my .zshrc. When I continued to run into this issue after this method of uninstalling rvm, I reinstalled rvm and uninstalled using the rvm implode process in case there were any other traces of rvm left that were causing issues. This also failed to fix the issue.

推荐答案

尝试一下。

在rails项目文件夹中检查 .ruby-version 文件是否存在,并放入指定到Gemfile中的相同红宝石版本中。
(如果此文件不存在,请创建它。)

In your rails project folder check the presence of .ruby-version file and put inside the same ruby version specified into Gemfile. (if this file is not present, create it.)

〜/ your-rails-project / .ruby-version 文件:

2.5.3

〜/ your-rails-project / Gemfile 文件:

source 'https://rubygems.org'
ruby '2.5.3'
...

然后使用rbenv安装该版本:

Then install that version with rbenv:

$ rbenv install 2.5.3
$ rbenv rehash
$ rbenv local 2.5.3
$ rbenv global 2.5.3

现在检查您使用的版本是否正确:

Now check that you are using the right version with:

$ ruby -v

这篇关于Rbenv使用的版本不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆