Rails not installing when following documentation - ruby-on-rails

$ sudo gem install rails
Successfully installed rails-3.1.1
1 gem installed
Installing ri documentation for rails-3.1.1...
Installing RDoc documentation for rails-3.1.1...
This did not properly work, as when I run rails, I get
The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails
And doing ruby --version gives
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
and doing which rails returns nothing. Anyone have any ideas about how I would go about installing the latest version of Rails? I've tries using the apt-get method, but I got Rails 2, however I need Rails 3 for my purposes.

I've had the similar problem with my Ubuntu installation.
Solved it following to steps:
Make sure rubygems is installed
created the following symlink:
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

Related

Ruby version not same as installed version

I am trying to install Ruby on rails on a Mac Mojave:
$ brew install ruby
Warning: ruby 2.7.1 is already installed and up-to-date
To reinstall 2.7.1, run `brew reinstall ruby`
This shows me that I am running Ruby 2.7.1.
But when I check the version I get:
$ ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
This tells me I am using Ruby 2.3.7.
I don't understand.
To run Rails I need >= 2.4.4 apparently:
$ sudo gem install rails
.....................
ERROR: Error installing rails:
zeitwerk requires Ruby version >= 2.4.4.
and
$ which ruby
/usr/local/opt/ruby/bin/ruby
So until I get ruby version to at least 2.4.4 I can't run rails.
Update
Install RVM on MAC as follows
$ brew install gpg
$ curl -L https://get.rvm.io | bash -s stable --autolibs=enabled --ruby
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
Got these instructions from:
https://null-byte.wonderhowto.com/how-to/mac-for-hackers-install-rvm-maintain-ruby-environments-macos-0174401/
But then I install Rails:
$ sudo gem install rails
Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed
and so I tried to crate a Rails project:
$ rails new blah
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.
What is going on there? I seem to have successfully installed Rails but cannot create a Rails project.
The output from this command brew install ruby is not telling you that you're running ruby 2.7.1. That just says you already have ruby 2.7.1 installed for brew. But you could have other ruby versions installed in other ways. When you do
ruby -v
ruby executable is looked for in paths listed inside your environment variable PATH, in order. You can see those paths with
echo $PATH
So, managing different versions of ruby is hard and version managers exist for this reason. I suggest you to install rvm

Rails Installation Error in ubantu12.04

I have already installed Ruby 1.9.3,gem 1.8.24, using RVM in ubantu 12.04. But when I instll rails using gem using command gem install rails , then rails is installed with following message:Successfully installed rails-3.2.6
1 gem installed
Installing ri documentation for rails-3.2.6...
Installing RDoc documentation for rails-3.2.6...
But when I check the version of rails then following error occurThe program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I need help. Thank you?
rvm use 1.9.3 --default
gem install rails
Then run rails -v
Try this:
run this command
source /etc/profile
Then, run rails -v
First try with
rvm list
to get all ruby version then run following cmd to set one of ruby as default
First you have to set
rvm use 1.9.3 --default
Then try cmd
rails -v

Cannot install rails gem

Somehow my rails installation hides itself successfully...
I have:
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
rvm 1.10.0-pre
gem 1.8.10
and I try to install rails:
sudo gem install rails
it works fine:
Successfully installed rails-3.1.3
1 gem installed
Installing ri documentation for rails-3.1.3...
Installing RDoc documentation for rails-3.1.3...
when I do:
rails - v
I get
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Also, when I do
rake
in a rails app root directory, I get:
Missing the Rails gem. Please `gem install -v= rails`, update your
RAILS_GEM_VERSION setting in config/environment.rb for the Rails version
you do have installed, or comment out RAILS_GEM_VERSION to use the
latest version installed.
executing
gem install -v= rails
raises an error:
ERROR: While executing gem ... (ArgumentError)
Illformed requirement ["="]
So apparently it is sitting somewhere and cannot be seen by my environment. I guess installing via apt-get is not an option as I don't want to confuse gem...
Any ideas?
Cheers
Mac
Do not use sudo.
Just gem install rails
Use RVM instead of the packaged ruby/gems distribution. http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

Fresh Rails install won't use version 3.1

I'm trying to install rails for the 1st time.
I can't seem to get it to install beyond Rails 2.2.3.
I have followed the instructions at:
http://rubyonrails.org/download
I downloaded the latest RubyGems and ran 'ruby setup.rb'.
$ gem -v
1.8.11
I ran 'gem install rails' and got Rails 2.2.3.
I ran 'gem update' several times and I get:
$ gem update
Updating installed gems
Updating rails
Successfully installed rails-2.2.3
Gems updated: rails
Installing ri documentation for rails-2.2.3...
Installing RDoc documentation for rails-2.2.3...
I tried gem1.8:
$ gem1.8 update
Updating installed gems
Updating rails
Successfully installed rails-2.2.3
Gems updated: rails
Installing ri documentation for rails-2.2.3...
Installing RDoc documentation for rails-2.2.3...
$ rails -v
Rails 2.2.3
$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
I'm using Debian 'unstable' (Wheezy/Sid).
I'm new to rails and don't understand what I'm doing wrong.
I've searched by so far nothing specific to this issue.
I thought the latsted gem would just get Rails 3.1
just as the install docs at the site say?
Any advise much appreciated.
Have you tried this ?
gem install rails --pre
I tried again and it worked fine now.
This time I pointed direct to the
fresh new copy of gem.
All good. Cheers!

Rails upgrade doesn't work

I'm using Ubuntu 10.10. When I run rails -v, I get 2.3.5. I want to upgrade to 3.0.5, so I run sudo gem install rails. I get
Successfully installed rails-3.0.5
1 gem installed
Installing ri documentation for rails-3.0.5...
Installing RDoc documentation for rails-3.0.5...
I run rails -v again. It still returns 2.3.5. I run sudo apt-get install rails, I get
Reading state information... Done
rails is already the newest version.
Anybody know what I'm doing wrong?
Look at your current gemfile, probably it has record only for rails 2.3.5, if it does then change to 3.0.5. After this just run bundle install

Resources