简体   繁体   English

使用RVM更改ruby版本后找不到捆绑包

[英]Bundle not found after changing ruby version with RVM

I feel like this is a super beginner question with an obvious answer but I'm missing it. 我觉得这是一个超级初学者的问题,有一个明显的答案,但我很想念它。

I'm installing a Rails project that includes a gem requiring me to use a version of Ruby that is 2.2.2 or earlier. 我正在安装一个包含gem的Rails项目,要求我使用2.2.2或更早版本的Ruby版本。 Since my current system is set up with a newer version of Ruby, when I run bundle install , it fails because one of the gems can't be installed with the newest version of Ruby. 由于我当前的系统使用较新版本的Ruby进行设置,因此当我运行bundle install ,它会失败,因为其中一个gem不能与最新版本的Ruby一起安装。

So, I set my system to use ruby 2.2.2 with rvm, rvm use ruby-2.2.2 . 所以,我将我的系统设置为使用ruby 2.2.2和rvm, rvm use ruby-2.2.2

I then run bundle install and get zsh: command not found: bundle . 然后我运行bundle install并获取zsh: command not found: bundle Why is this? 为什么是这样? All my other commands work and I can install the problem gem individually with gem install . 我的所有其他命令都可以工作,我可以使用gem install单独安装问题gem。

What am I missing? 我错过了什么?

You probably had Bundler installed for the version of ruby you've been using until this point. 你可能已经为你一直使用的ruby版本安装了Bundler,直到这一点。 However, Bundler is not installed on versions of ruby provided by RVM by default, so for after you switch to ruby-2.2.2, install Bundler for that ruby: 但是,默认情况下,在RVM提供的ruby版本上没有安装Bundler,因此在切换到ruby-2.2.2之后,为该ruby安装Bundler:

gem install bundler

Then try running bundle install again. 然后尝试再次运行bundle install

If you just switched to a new version of ruby on your RVM install 2.2.2 in this case the 如果您刚刚在RVM安装2.2.2上切换到新版本的ruby,在这种情况下

  gem install bundler 

command listed as correct above is only going to solve this error for that single gemset. 上面列出的正确命令只能解决该单个gemset的这个错误。 I would suggest running the following command to avoid it for any other gemsets also tied to the same version of ruby. 我建议运行以下命令,以避免任何其他gemset也绑定到相同版本的ruby。

  rvm use 2.2.2@global
  gem install bundler

That will put the bundler gem into your global 2.2.2 gemset making it available but over writable by all other 2.2.2 gemsets. 这将把bundler gem放到你的全局 2.2.2 gemset中,使其可用,但是所有其他2.2.2 gemset都可以写入。 You can also install gems like nokogiri and such that are common but very time consuming into this global 2.2 gemset 您还可以安装像nokogiri这样的宝石,这些宝石在这个全球2.2宝石集中很常见但非常耗时

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

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