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
Related
I initially created my environment will ruby 2.6.3 via the tutorial I was following and the practice app. I started building my own custom app and when I realized via Heroku that I wasn't using the most current version of Ruby (3.0.1). So I upgraded the root environment, but my app continues to use 2.6.3 even though I updated the Gem File.. I keep getting this message Your Ruby version is 2.6.3, but your Gemfile specified 3.0.1 I can fix this temporarily by running rvm use 3.0.1, but I have to do this every time I start a new terminal.
Somewhere online someone said to run bundle env to get the ruby version and path. so here is that information
Bundler 2.2.17
Platforms ruby, x86_64-linux
Ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
Full Path /home/ubuntu/.rvm/rubies/ruby-2.6.3/bin/ruby
Config Dir /etc
RubyGems 3.0.3
Gem Home /home/ubuntu/.rvm/gems/ruby-2.6.3
Gem Path /home/ubuntu/.rvm/gems/ruby-2.6.3:/home/ubuntu/.rvm/rubies/ruby-2.6.3/lib/ruby/gems/2.6.0
User Home /home/ubuntu
User Path /home/ubuntu/.gem/ruby/2.6.0
Bin Dir /home/ubuntu/.rvm/gems/ruby-2.6.3/bin
Tools
Git 2.17.1
RVM 1.29.12-next (master)
rbenv not installed
chruby not installed
rubygems-bundler (1.4.5)
Can't seem to find a clear answer on what to change to permanently have my app use 3.0.1.
Did you add .ruby-version?
If not, add .ruby-version file to under your project path and put it ruby version
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
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
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.
i'm trying to upgrade my server from ruby 1.8 to 1.9 and i did that with following link.
[http://kb.site5.com/ruby-on-rails/select-a-version-of-ruby-for-your-hosting-account/]
i did all the things, Now
ruby -v : ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
but when i run bundle install it installs it in /vendor/bundle/ruby/1.8 folder.
but when i try to run the code it checks in /vendor/bundle/ruby/1.9.1 folder.
i can't seem to run my site. i specified ruby "1.9.3" in gem filoe and try to tun bundle install it gives me an error "your ruby version is 1.8.7 but your gemfile specified 1.9.3"
which ruby : /user/local/ruby19/bin
i changed gemrc cat .gemrc
gempath: [/opt/ruby/lib/ruby/gems/1.9.1,
/home/XXX/ruby/gems] also.
my site says bundle install error
After that i tried to copy all the gems from 1.8 folder to 1.9 in vender because it was looking there then i got this error because nokogir was insalled for 1.8 and needed higher version.
Any idea?? i have been stuck here from hours!!!