Bundler is removing RUBY VERSION from Gemfile.lock - ruby-on-rails

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

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.

Installed Ruby version are different in macOS and Bundle

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.

Rails Seeing Incorrect Ruby Version

I've built a Rails 5 app and it's working great but I'd like to change the Ruby version I'm running it on. I'm using RVM 1.27.0 on Ubuntu 16.04. I copied the app folder to a different path and changed the versions on .ruby_version and my Gemfile:
Gemfile:
source 'https://rubygems.org'
ruby "2.2.2"
.ruby_version:
ruby-2.2.2
Once I updated these I moved out and back into the folder and ran a ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
I then ran a bundle install and everything installed without error.
However, when I ran rake -T I get this:
Your Ruby version is 2.3.1, but your Gemfile specified 2.2.2.
My $PATH looks good:
/home/ken/.rvm/gems/ruby-2.2.2/bin:/home/ken/.rvm/gems/ruby-2.2.2#global/bin:/home/ken/.rvm/rubies/ruby-2.2.2/bin:/home/ken/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
What am I missing? Where is Rails pulling the Ruby version from? How can I fix this?
You're using a system bundler which is why you're seeing a different version of ruby. All you need to do is install bundler under your current ruby version:
gem install bundler
bundle install
Once you do a bundle install you'll get the gem's built for the correct ruby version.
The file name should be .ruby-version, not .ruby_version.
And you also should have file .ruby-gemset with content
gemset
check this link, Create .ruby-version and .ruby-gemset with rvm
You can also try spring stop and gem 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.

Resources