0

There were so many questions on this topic but none could help me to solve the issue.I am new to ROR. I am trying to run following command

rake db:create

it throws error though I have ruby 2.2.1 installed and by default it is pointed to

Your Ruby version is 1.9.3, but your Gemfile specified 2.2.1

I tried running following commands to check which ruby version is being used

ubuntu@myserver:~/workspace/railpro/appraiser-events/bin$ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
ubuntu@myserver:~/workspace/railpro/appraiser-events/bin$ which ruby
/home/ubuntu/.rvm/rubies/ruby-2.2.1/bin/ruby
ubuntu@myserver:~/workspace/railpro/appraiser-events/bin$ echo $PATH
/home/ubuntu/.rvm/gems/ruby-2.2.1/bin:/home/ubuntu/.rvm/gems/ruby-        2.2.1@global/bin:/home/ubuntu/.rvm/rubies/ruby-    2.2.1/bin:/home/ubuntu/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ usr/bin:/sbin:/bin:/usr/games:/usr/local/games

This shows that i am using ruby 2.2.1 and in my Gemfile also it points to 2.2.1 but when I use rake db:create it throws this error.

When I tried to change the Gemfile to point to 1.9.3 it said the reverse

Your Ruby version is 2.2.1, but your Gemfile specified 1.9.3

I tried putting a .ruby-version file in the top level directory and mentioned the 2.2.1 inside that but it didn't work

  • From which directory are you trying to run the rake command? What happens if, from the root directory of your app (where your Gemfile sits), try to run `bundle exec rake db:create` ? – Marco Sandrini Sep 02 '15 at 02:55
  • I was executing the command from app-name/bin directory. I tried executing the suggested command from the root directory of the app and it throws the same error `Your Ruby version is 1.9.3, but your Gemfile specified 2.2.1` – user2067531 Sep 02 '15 at 05:19
  • possible duplicate of [In Ruby: "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0"](http://stackoverflow.com/questions/19342044/in-ruby-your-ruby-version-is-1-9-3-but-your-gemfile-specified-2-0-0) – orvi Sep 02 '15 at 05:21
  • I have gone through all the solutions suggested there but none of the solutions worked for me – user2067531 Sep 02 '15 at 06:15
  • Have you installed rvm? Or rbenv, or any other equivalent? – Marco Sandrini Sep 02 '15 at 07:20
  • yes it's installed. `ubuntu@myserver:~$ rvm -v rvm 1.26.11 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/] ubuntu@myserver:~$ rbenv -v rbenv 0.4.0 ` – user2067531 Sep 02 '15 at 07:39
  • You have BOTH rvm and rbenv? – Marco Sandrini Sep 02 '15 at 12:18

1 Answers1

1

Run with bundle exec:

bundle exec rake db:create

This will ensure that the rake command is executed in the context of the current bundle.

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110