简体   繁体   English

Rbenv的Ruby版本问题

[英]Ruby version issues with Rbenv

I am setting up my new machine (Mac Yosemite) and when I run the command "bundle" I get the following error: 我正在安装我的新机器(Mac Yosemite),当我运行命令“ bundle”时,出现以下错误:

Your Ruby version is 2.2.1, but your Gemfile specified 2.2.0 您的Ruby版本是2.2.1,但是您的Gemfile指定了2.2.0

I'm trying to change the version w Rbenv but I think it's not working. 我正在尝试更改Rbenv的版本,但我认为它不起作用。

ruby -v
// Ruby 2.2.1p85

rbenv version
// 2.2.0

Can anyone help me? 谁能帮我? Thanks in advance! 提前致谢!

尝试使用rbenv local [version number] 。有关更多信息,请参考内容。

I had a similar problem but with ruby -v 2.2.0 and Mac OSX El Capitan. 我有一个类似的问题,但是使用ruby -v 2.2.0和Mac OSX El Capitan。 What finally worked for me was: 最终对我有用的是:

  1. gem install bundler (apparently it was no longer installed) gem install bundler(显然已不再安装)
  2. rbenv rehash rbenv rehash
  3. bundle install 捆绑安装

I was able to find the answer on the github for rbenv. 我能够在github上找到rbenv的答案。 https://github.com/sstephenson/rbenv/issues/697 https://github.com/sstephenson/rbenv/issues/697

Assuming you have Ruby -v 2.2.0 installed ( rbenv install 2.2.0 otherwise), change your ruby version with rbenv : 假设您已安装Ruby -v 2.2.0( rbenv install 2.2.0 ),请使用rbenv更改您的ruby版本:

rbenv global 2.2.0

after install rails you must do this: rbenv rehash , in order to tell rbenv to see rails as executable. 安装rails之后,您必须执行以下操作: rbenv rehash ,以便告诉rbenvrails视为可执行文件。

follow this tutorial to set up Ruby and Ruby on Rails in your machine: https://gorails.com/setup/osx/10.10-yosemite 请按照本教程在您的机器上设置Ruby和Ruby on Rails: https : //gorails.com/setup/osx/10.10-yosemite

Note: In my case. 注意:就我而言。 after install rbenv the command rbenv global 2.2.0 doesn't affect my current ruby version ( ruby -v still be the previous one). 安装rbenv ,命令rbenv global 2.2.0不会影响我当前的ruby版本( ruby -v仍然是前一个)。 I fix this issue reinstalling rbenv and run this command: 我修复了重新安装rbenv并运行以下命令的问题:

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

immediately afterwards, as explained above in the tutorial. 之后,立即按照本教程中的说明进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM