简体   繁体   中英

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 . 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. In addition I use rvm to manage the versions and when I list them with rvm list the output is:

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?

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

You can use sudo bundle exec rake db:seed , sudo bundle exec bundle .

Using bundle exec makes everything standardized according to your current Gemfile. See: What does bundle exec rake mean?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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