Installed Ruby version are different in macOS and Bundle - ruby-on-rails

I'm not using RVM but brew to install and update Ruby and Gem version up-to-date. But when I was trying bundle install, I got an error showed that the Ruby version requirement does not conform.
I added ruby '2.1.9' to the Gemfile and did some check:
(●—●) ↪ bundle platform
Your platform is: universal.x86_64-darwin16
Your app has gems that work on these platforms:
* ruby
Your Gemfile specifies a Ruby version requirement:
* ruby 2.1.9
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.9
(●—●) ↪ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
(●—●) ↪ gem -v
2.6.11
I found that there is a lower version Ruby in my project.
/Users/veck/Desktop/Project/vendor/bundle/ruby/2.0.0
How do I fix this problem?

I found that I successfully did bundle install with following action:
gem install bundler
After this installation, my vendor/bundle/ruby has one more version 2.4.0. Then I retry bundle install and all works fine.
Note: But 2.0.0 version of ruby still stay in vendor/bundle.

Related

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

Mismatched ruby version after downgrade from 2.4.1 to 2.3.3 while running bundle install

While attempting to solve another issue identified in this thread:
Error while trying to load the gem 'devise. ActiveSupport: Duration can't be coerced into Integer, I followed the suggested solution and changed my ruby version from 2.4.1 to 2.3.3 using rbenv. I also made similar changes in my Gemfile to reflect the new ruby version. However, when I tried to bundle install again, it throws an error saying that my ruby version is 2.4.1, when my Gem specified 2.3.3. However, running ruby -v shows my ruby version is on 2.3.3.
$ bundle install
Your Ruby version is 2.4.1, but your Gemfile specified 2.3.3
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
Any help here would be appreciated. Thank you!
Gem installation is specific to ruby version, so the bundler you're using is likely installed to your old ruby. Try installing bundler again:
gem install bundler
That should fix your problem.

Bundler is removing RUBY VERSION from Gemfile.lock

I'm having the opposite issue to this one. The Gemfile has:
source 'https://rubygems.org'
ruby '2.3.1'
At the end of my Gemfile.lock file is:
RUBY VERSION
ruby 2.3.1p112
BUNDLED WITH
1.12.4
But when I run bundle install is always deleting RUBY VERSION regardless I'm using the same as the development team's version. Even I'm using a more recent bundler version than the used to generate the original Gemfile.lock file:
$ bundle -v
Bundler version 1.12.5
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Any ideas how can I stop this?
After a couple of days I stumbled upon another problem where I had to run spring stop. After that it started to generate it correctly.
My bad for suspending my pc and have running those processes for weeks instead of trying the good old shutdown.
I had the same problem - at the end of Gemfile.lock there were following lines:
RUBY VERSION
ruby 2.4.1p111
BUNDLED WITH
1.16.4
As long as I was using bundler in version 1.3.0 gem those lines have been automatically removed from Gemfile.lock.
The problem stopped after changing the bundler version to the one pointed by BUNDLED_WITH parameter.
The command I used:
gem uninstall bundler & gem install bundler -v 1.16.4

Your Ruby version is 2.2.4, but your Gemfile specified 2.3.0?

I'm trying to bundle install a ruby project in Git Bash but I'm getting the above message.
ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i836-mingw32]
gem -v
2.3.0
New to Ruby so its really frustrating. I'm trying to do the project below
http://www.viralrails.com/?p=25
This happens because you are specifying a Ruby version in your Gemfile (2.3.0) and this version is not installed or is not the current or default version.
Don't remove the line ruby '2.3.0' as someone said above. You app may have dependencies to this version. Do the following:
1) Check if you have Ruby 2.3.0 installed. If you are using rvm this may be done by
rvm list
and if you are using rbenv by
rbenv versions
2) If you don't have this Ruby version in your list of installed versions, then install it by issuing the following command
rvm install 2.3.0
and if you are using rbenv by
rbenv install 2.3.0
3) If you already had Ruby 2.3.0 installed or completed step 2 above, enter your app directory and issue the following command
rvm use 2.3.0
and if you are using rbenv by
rbenv local 2.3.0
Then run
bundle install
and I believe things will be ok.
Hope it helps!
Install bundler after installing ruby 2.4.0.
gem install bundler
If you installed bundler before installing ruby 2.4.0 then you should reinstall bundler or update it.
Also if the above command didn't work.
gem update 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.

Resources