简体   繁体   English

Rails须藤+ <any command> 将抛出不同版本的ruby(安装的vs. Gemfile)的错误

[英]rails sudo + <any command> will throw an error of different ruby versions (installed vs. Gemfile)

Every time a command is executes with sudo (for instance: sudo rake db:seed or sudo bundle ) an error is thrown: Your Ruby version is 1.9.3, but your Gemfile specified 2.2.1 . 每次使用sudo执行sudo (例如: sudo rake db:seedsudo bundle )时,都会引发错误: Your Ruby version is 1.9.3, but your Gemfile specified 2.2.1 When I hit ruby -v it's ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] so I guess it's not the problem. 当我点击ruby -v ,是ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]所以我想这不是问题。 In addition I use rvm to manage the versions and when I list them with rvm list the output is: 另外,我使用rvm来管理版本,当我用rvm list列出它们时,输出为:

rvm rubies

=* ruby-2.2.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

So what causes this error to be thrown? 那么是什么导致引发此错误呢? It has something to do with the root user configuration? 它与root用户配置有关吗?

您可以尝试使用命令rvmsudo (更多信息在此处 )。

You can use sudo bundle exec rake db:seed , sudo bundle exec bundle . 您可以使用sudo bundle exec rake db:seedsudo bundle exec bundle

Using bundle exec makes everything standardized according to your current Gemfile. 使用bundle exec可根据您当前的Gemfile将所有内容标准化。 See: What does bundle exec rake mean? 请参阅: 捆绑程序执行度耙是什么意思?

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

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