Can't update to rails 5 because of ruby version - ruby-on-rails

I am planning to run ruby 2.3.1 version with Rails 5 on Mac OSX.
1 I installed rbenv then install ruby version 2.3.1.
rbenv version
2.3.1 (set by /D/testProject/.ruby-version)
2 Update gem
gem update --system
Latest version currently installed. Aborting.
3 System ruby version:
ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
But when i run gem update rails, i got
ERROR: Error installing rails:
activesupport requires Ruby version >= 2.2.2.
So my question is how to make the gem update rails according to rbenv ruby version, not system version? Then i can update to Rails 5.
or
Do i have to update my system version of ruby to update to Rails5.
EDIT
I have ran rbenv local 2.3.1 (.ruby-version was created) already. But still can't update to Rails5
Thank you!
EDIT
which ruby
/usr/bin/ruby

I update my system version of ruby solved the issue.
brew install ruby

you can use this command:
$ rbenv local 2.2.2
(this will generate a .ruby-version file)

Assuming you have already updated ruby using something like
sudo gem update --system
You can then set the rvm gemset lst to use the global version(s) installed.
rvm gemset list
rvm gemset use global -save

Related

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

"Rails is not currently installed" Error

Hi i'm new to ruby on rails
I have 3 ruby version in my computer.
In a project i had to use rails 3.2.1 and ruby 1.9.2
So I switched using rvm use 1.9.2 in terminal. But after that my rails commands are not detected.
$ rails g model abc
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Why is this happening? And how to solve this?
You may need to differentiate your gem set that contains that specific version of rails from the old ones.
rvm use 1.9.2#new_gem_set_of_yours --create --default
And then retry installing the 3.2.1 rails
gem install rails --version 3.2.1
Or specify the new rails version in your Gemfile and let Bundler take care of it
gem 'rails', '3.2.1'
and run bundle install.
Type in your terminal
gem install rails -v 3.2.1
if it does not work, first try
rvm install 1.9.3
then
rvm rubygems current
and repeat.

Rbenv Version 2.1.1, but Error Says Ruby Version is 2.0.0 [duplicate]

This question already has answers here:
How to fix "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0"
(21 answers)
Closed 8 years ago.
I'm on Mac/Mavericks, using rbenv and this rail 4 repo. My rbenvs version is set to 2.1.0, I uninstalled RVM, but when I type in ruby -v it says ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] what do I need to do to make rbenv the default service for my ruby version?
However, the annoyance is working with my rails app. When I change ruby in my Gemfile to 2.1.1 and bundle install, it says my ruby version is 2.0.0. When I change my version to 2.1.1, it says my Ruby version is 2.0.0.
What do I need to do to set my ruby version to 2.1.0 so the Gemfile can recognize it?
Bash_profile:
export PATH=/usr/local/bin:$PATH
PS1='\W \u\$ '
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/shims:$PATH"
Bundler is trying to tell you that the version of Ruby you have loaded is not matching the one you specified in your Gemfile.
rbenv install 2.1.0 && rbenv local 2.1.0
Was it Spring, maybe? Try spring stop
See How to fix "Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0" for details.
I've actually noticed that message showing up if you don't install bundler right off the bat in the new ruby version before trying to perform a bundle update.
Your Ruby version is 2.0.0, but your Gemfile specified x.x.x
In my case I was moving from the Ruby 2.0 that comes with Mavericks to Ruby 1.9.3p125 with rbenv. I believe the shell will try using whatever bundle binary that is available. My solution was just:
gem install bundler

Rails is not using my global Ruby version

I want to use Rails with Ruby 2.1.0, but it's using Ruby 1.9.3 (the system's version).
I'm using rbenv to manage my Ruby versions. My steps were something along the lines of:
$ rbenv install 2.1.0
$ rbenv global 2.1.0
$ sudo gem install rails -v 4.0.2
$ rbenv rehash
$ rbenv versions
system
* 2.1.0 (set by /home/dennis/.rbenv/version)
$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
$ rails new app && cd app
$ rails server
Rails is using is Ruby 1.9.3 (x86_64-linux), according to localhost:3000/rails/info/properties. A log message from rails server gives: INFO ruby 1.9.3 (2012-04-20) [x86_64-linux].
I think Rails is using the system version of Ruby because the versions match.
$ rbenv local system
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
$ rbenv local --unset # Unset local Ruby version, go back to 2.1.0
Some things I've tried with no luck:
setting the local and shell versions of Ruby to 2.1.0 with rbenv
rehash rbenv shims (rbenv says to do this after installing executables)
made new Rails projects after switching to 2.1.0 just in case I made the projects while using 1.9.3
putting 2.1.0 in a .ruby-version file in the root of my project (suggested by #Agis)
restarting terminal session and starting a login bash shell (suggested by #Russel)
specifying the desired Ruby version in the project's Gemfile (suggested by #rlecaro2)
FWIW, I'm using Ubuntu 13.10 with the fish shell.
Sounds silly, but did you restart terminal session?
Otherwise try and type
/bin/bash --login
You didn't tell how you installed rbenv, but I think it is per-user installation (which is default). In this case you should install gems without using sudo. When you did sudo gem install rails, it was installed in system ruby, not rbenv's selected one.
Solution - install rails without sudo:
rbenv global 2.1.0
gem install rails
rbenv rehash
Try creating a .ruby-version file in the root of your project with the following contents:
2.1.0

Ruby version - Error installing Rails

I'm getting the next error installing RoR
How can I set the correct Ruby Version?
#####:path$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
#####:path$ sudo gem install rails
ERROR: Error installing rails:
activesupport requires Ruby version >= 1.9.3.
#####:path$
You shouldn't have to use sudo with gem install .... That's what's causing the mismatch between Ruby versions, since root is using the default installed Ruby, whereas your own account is using RVM's installed version.
Updating the system version of Ruby depends on your operating system, and usually lags behind the very latest version of Ruby. I've been using 2.0 for my latest project I launched last month. I doubt big OS vendors like Ubuntu or Apple are providing that version in their latest distribution. It's best that you manage your own Rubies whenever possible.
To install 1.9.3 you can run:
$ rvm install 1.9.3
then later
$ rvm use 1.9.3
You have :
###:path$ ruby -v
.....
###:path$ sudo gem install rails
...you said in your comment that :
$ sudo ruby -v
...gives you
ruby 1.8.7
To resolve this problem you shouldn't use sudo, as it tries to install using root session with 1.8.7 ruby version which is not supported.
To install rails just type the following without sudo:
$ gem install rails
...it should works as you've a supported ruby version (ruby 2.0.0p247)
You can check Install Ruby on Rails ยท Ubuntu Linux instructions (Which I found useful) if you've more troubles.

Resources