Ruby on Rails set up - ruby-on-rails

I am currently following the rails guide to create a blog app.
When I run.
ruby -v #ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin16].
I have already ran:
gem install rails
bundle install
I just reached step 4.1, then I ran
bin/rails server
and I am encountering the following error

It's a warning, and not an error. It's clearly suggesting: upgrade to 2.3.1
The server is up and running anyway.
If you are using rvm, rvm install ruby-2.3.1 will do it for you.

Related

Trying to install Rails 6 using RVM

I have installed RVM successfully on my Mac and using it I have installed Ruby 2.6.3. I have set my current and default version of Ruby to be 2.6.3. Everything seems to be fine because when I enter ruby -v into the terminal it tells me I'm using ruby 2.6.3.
My problem comes when I try to install Rails 6, I'm entering:
gem install rails --version=6.0.0 -no-ri -no-rdoc
It seems to install correctly however when I try to confirm with:
rails -v
I get:
Rails 6 requires Ruby 2.5.0 or newer.
You're running
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64- darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.
Why am I getting this message when my ruby -v command is telling me that I am using ruby 2.6.3
Any help would be very welcome.
You're running ruby 2.3.7p456. You need to set your local ruby version to 2.6.3.
Try which ruby to see which ruby version is loaded.
rvm install 2.6.3
rvm use 2.6.3
You can then see which ruby is running with which ruby.
See the basics on the rvm docs
As an aside, I also recommend recommend rbenv over rvm; however, you can only have one installed. If you have both installed, you're going to have a bad time.
To make sure you do not have both installed try which rbenv, and that should return rbenv not found
Please edit your original question with the output of the following commands:
which -a ruby
echo $PATH (That will help debug if your $PATH is set up incorrectly.)
which rbenv
ls (in your project directory)
i also had the similar problem which i resolved by uninstalling rvm completely and then installing rbenv.

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.

Gem install rails throwing an UnknownHostError

I am trying to get my rails environment working on a mac with the latest mac OS. I have ruby installed...
ruby -v
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin14.0]
When I try to start a rails server I get this message...
rails -s
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
So I run 'sudo gem install rails' and get ....
ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
no such name (https://api.rubygems.org/gems/thread_safe-0.3.4.gem)
How would I get around this error?
DNS issue with rubygems is now resolved so all is well, thanks again Shibi for the status update!

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.

Trying to install Rails 3, getting a strange "Ruby upgrade" notice

I'm trying to get my computer (Mac OS X, running Leopard) running with the latest version of Rails. Before this, I had 2.3.5. I tried following some instructions a few days ago, but didn't seem to make much progress. Now, I can't do anything in Rails. You'll see what I mean in a sec.
Theoretically, I've got the latest versions of Ruby:
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
$ sudo ruby -v
Password:
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9]
But if I try to run Rails, I get this error message:
$ rails testapp03
Rails requires Ruby version 1.8.7 or later.
You're running 1.8.6 (2008-08-11); please upgrade to continue.
And if I try to see which version of Rails I'm using, I get the same:
$ rails -v
Rails requires Ruby version 1.8.7 or later.
You're running 1.8.6 (2008-08-11); please upgrade to continue.
In case these are useful:
$ which ruby
/opt/local/bin/ruby
$ sudo which ruby
Password:
/opt/local/bin/ruby
$ which rails
/usr/bin/rails
So, the question: What have I done, and what do I need to do to get Ruby / RubyGems / Rails up and running on my computer?
What does which gem return?
Probably, your Ruby installation points to /opt/local/bin/ while the gem command is still referencing /usr/bin/.
When you installed the Gem, the Gem was saved in /usr/bin/ and loads the original system Ruby.
I don't know how you installed Ruby 1.8.7, however I would suggest you to take a step further: remove all your Ruby versions (except the system one, of course) and try RVM.
Try executing this command /opt/local/bin/ruby -v from the command line and see what version of ruby that come out.
Next find out where is the ruby gems is located with whereis ruby. I assume it should near /opt/local/lib/ruby-x.x/gems/.... Also try find out whether rails is installed under those directories. If not, your rails might be still pointing to the old ruby.
Also check if you have /usr/bin/ruby? If so, what is the output of /usr/bin/ruby -v ?
If it exists and rails is pointing to that version, So you should uninstall that ruby and rails, and install the rails gem all over again with /opt/local/bin/ruby

Resources