Ruby -v gives me one version and Gemfile gives me another - ruby-on-rails

I'm in a local repository running the command
bundle install --without production
and I get an error message saying
Your Ruby version is 2.0.0, but your Gemfile specified 2.2.2
I just installed Ruby version 2.2.2 and using the gem environment command I'm able to see I have version 2.2.2 however, ruby -v gives me
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
I have tried adding 2.2.2 to my .ruby-version file in the root directory, as well as updating the bundler and typing bundle exec rails s
but it still gives me the same error.

Related

Your Ruby version is 2.7.0, but your Gemfile specified 2.6.3 but I have ruby 2.6.3 installed

So my gemfile specifies ruby '2.6.3' and I used rbenv to install ruby 2.6.3. However, when I try to run rake db:create, it gives me an "Your Ruby version is 2.7.0, but your Gemfile specified 2.6.3" error. I even check my ruby version using ruby -v and it even tells me I have 2.6.3. Can someone explain why this is occurring?

How to fix 'Your Ruby version is 2.3.3, but your Gemfile specified 2.5.2'

I got an error: Your Ruby version is 2.3.3, but your Gemfile specified 2.5.2 with running bundle install.
Besides, ruby -v shows ruby 2.5.2p104 (2018-10-18 revision 65133) [x86_64-linux].
OS: Debian 9
Problem with bundler was solved with: Your Ruby version is 2.0.0, but your Gemfile specified 2.1.0
But now there is the same error with rails s
The problem was solved by,
rvm reinstall ruby-2.5.2
rvm default use ruby-2.5.2
bundle install
bin/rails s

Your Ruby version is 2.3.1 but your Gemfile specified 2.5.1

Whenever I run a Rails command, it states that my Ruby version is 2.3.1 but my Gemfile specified 2.5.1. However, "ruby -v" returns "ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]", my path has no references to ruby 2.3.1, and running "rvm list" shows a properly green highlighted 2.5.1. Bundler is installed, and when I try to run bundle install inside a created Rails folder, a get another "Your Ruby version is 2.3.1 but your Gemfile specified 2.5.1" message. Please advise.
$PATH:
-bash: /home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/usr/share/rvm/rubies/ruby-2.5.1/bin:/usr/share/rvm/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/bin:/home/alowverus/.local/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1#global/bin:/home/alowverus/bin:/home/alowverus/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory
Further information in response to answers:
"which rails" returns "/home/alowverus/.rvm/gems/ruby-2.5.1/bin/rails", as expected
Create two files in the root one .ruby-version mention ruby-2.3.1 and .ruby-gemset mention #gemset-name and cd back to the same directory which will create the rvm wrapper for that application then run
rvm current
which outputs like something
ruby-2.3.1#gemset-name
then run
gem install bundler
bundle
may be helpful for you
I would try (in no particular order):
which rails, is it the correct one?
bundle exec rails c (or whatever your command is)
rvm reload
To start clean, rvm implode and try reinstalling rvm and your Ruby version.
Your Ruby version is 2.3.8, but your Gemfile specified 2.3.1
check ruby version with ruby -v [version like 2.3.8] make sure ruby version should be same on ruby versions as well as in your GemFile if you have not the same version then your put command on your bash_profile (terminal) rbenv global 2.3.8 & rbenv shell 2.3.8 (the version you can specified accordingly ) then delete your Gemfile.lock then install bundle and install bundler . these steps working form me.
rbenv global 2.3.8
rbenv shell 2.3.8
delete your Gemfile.lock
install bundle
install bundler

Ruby Gemfile does not match Ruby Version, but does match ruby -v output

I have a rails app and I am kinda new rails.
My main issue is that I am on a production server and cannot run bundle.
It gives this error:
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
So, I have tried to use rbenv, but it was not sucessful as can be seen below.
$:/home/deploy/my-app/current$ rbenv global 2.1.7
$:/home/deploy/my-app/current$ bundle
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
$:/home/deploy/my-app/current$ ruby -v
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]
Using RVM seems to be what others are using in other questions, but I really just want one version of ruby running (the one that is specified)
This server is going to be the production but is currently not live.
EDIT 1: gem install bundler
I have tried installing bundle while in ruby 2.1.7 but this did not work.
Here is what I did:
$:/home/deploy/my-app/current$ ruby -v
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux]
$:/home/deploy/my-app/current$ gem install bundler
Fetching: bundler-1.11.2.gem (100%)
Successfully installed bundler-1.11.2
Parsing documentation for bundler-1.11.2
Installing ri documentation for bundler-1.11.2
Done installing documentation for bundler after 4 seconds
1 gem installed
$:/home/deploy/my-app/current$ bundle
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
EDIT 2 which bundle
$:/home/deploy/my-app/current$ which bundle
/usr/local/bin/bundle
Try to create a .ruby-version file, specifying the ruby version 2.1.7.
When you enter the project directory, the rbenv will use the correct ruby version.
After that, reenter the project directory and execute bundle exec bundle.

Your Ruby version is 1.9.3, but your Gemfile specified 2.2.1

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
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.

Resources