1

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?

benams
  • 4,308
  • 9
  • 32
  • 74

2 Answers2

1

You can try command rvmsudo (more information here).

hedgesky
  • 3,271
  • 1
  • 21
  • 36
0

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?

Community
  • 1
  • 1
aaron-coding
  • 2,571
  • 1
  • 23
  • 31
  • Ok, try `sudo bundle exec bundle` first, then back to that command. This first command should set up your gems to match your gemfile, than you can do the other once you have the correct gem configurations. – aaron-coding Jun 16 '15 at 17:34
  • got the same error for the `sudo bundle exec bundle` command. – benams Jun 16 '15 at 17:41
  • In my opinion, rvm is troublesome and not easy to debug. You can follow this gist to switch to rbenv: https://gist.github.com/brentertz/1384279 once you're using rbenv things should be easier with ruby versions. Otherwise, not sure what the issue is as `bundle` or `sudo bundle` should be installing your correct ruby version. – aaron-coding Jun 16 '15 at 18:06