Trying to install Rails 6 using RVM - ruby-on-rails

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.

Related

Cannot install rails version 4.2.5 on Ubuntu in WSL when I have ruby 2.2.1 active. nokogiri requires Ruby version >= 2.3.0

Trying to install rails version 4.2.5 on Ubuntu in Windows Subsystem for Linux on Windows 10 when I have ruby 2.2.1 installed and active I get the following error:
~$ gem install rails -v 4.2.5
ERROR: Error installing rails:
nokogiri requires Ruby version >= 2.3.0.
I need these versions to collaborate on a project which uses these versions.
I started by installing WSL (1 not 2) on windows 10, then downloaded and installed Ubuntu Linux. Then I installed rbenv, updated dependencies, installed ruby 2.5.1 which was fairly easy.
I had problems installing ruby 2.2.1 but got there after doing
$ sudo apt-get install -y libssl1.0-dev
to install an earlier version of libssl which ruby 2.2.1 needs.
I installed node.js and an earlier version of bundler using
$ gem install bundler -v 1.17.3
as trying
$ gem install bundler
failed with a similar error.
(I also installed ruby 2.5.1 and rails 4.2.5 on top of it with few problems)
Trying various diagnostics showed rails was not installed for ruby 2.2.1
~$ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.5.1
(but not in ruby 2.2.1, which is where I need it)
Looking at my files in windows File Explorer (only looking) I can see that while my ruby 2.5.1 gems include rails my ruby 2.2.1 files are incomplete and do not include rails.
I think the PATH is correct.
$ echo $PATH returns
/home/johnloughran/.rbenv/plugins/ruby- build/bin:/home/johnloughran/.rbenv/shims:/home/johnloughran/.rbenv/bin:/usr/
local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local
/games:/mnt/c/Program
Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2019.522.0_
x64__79rhkp1fndgsc: ........ :/snap/bin
I modified my .bashrc file to add various entries to the PATH which have been included above.
I repeated the whole process twice starting from scratch (uninstalling Ubuntu) with the same block at the end.
What is my best option here to try and continue?
Thanks Josien for your comments. In the first case my collaborators have these versions of Ruby and Rails working together, but its a few years now since they installed them. One, David, helped me by trying a fresh install of rails 4.2.5 on ruby 2.2.1 which ran into the same problem above with nokogiri.
He solved it by installing a lower version of nokogiri in a new test directory, which I repeated as:
test$ gem install nokogiri -v 1.9.1
This worked. Then I installed rails as
test$ gem install rails --version 4.2.5
At last .... it worked!!!! :-)
To prove it I was able to get rails to return its version correctly.
test$ rails -v
Rails 4.2.5
Then I was able to create an app as
<working-directory>$ rails new learn-ruby
which works, almost, having hit another dependency problem, but hey ... that's programming!
Re your second comment I do not know enough about this stuff to know how relevant it is that this version of ruby is deprecated and the rails version is getting there too.

Cannot create a new Rails app

I am running Ruby -v 2.2.0
Everytime I run the rails new or rails -v I get an error that reads:
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.2.0
I was running Ruby 2.1.5 but just switched to 2.2.0 because of the error message. Now that I switched I am still getting the same error message. Does anyone know what the problem could be?
Every installed ruby version have separate set of gems.
This rbenv message says that rails gem installed only in 2.2.0 version but currently rbenv set to use some another version.
You can list of available rbenv commands by rbenv command in terminal. There are some useful of them which may help to solve this question:
rbenv versions will display all installed ruby versions (and show asterisk with currently selected version).
rbenv global 2.2.0 will set global Ruby version.
rbenv local 2.2.0 will set Ruby version for current folder only.
rbenv shell 2.2.0 will set Ruby for current shell session only.
It could be that proper version of Ruby not installed. Install it and Bundle:
rvm install 2.2.0
bundle install

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.

Which Ruby version am I really running?

I'm running Ubuntu 12.04 LTS, and installed Ruby via RVM.
The problem is, when I type ruby -v into the terminal, it says that my Ruby version is 1.8.7, and using the shotgun gem for Sinatra also says that I'm running Ruby 1.8.7.
But when I type rvm list it shows that the only version of Ruby that I have installed is 2.0.0 and it is my current and default version.
I installed Ruby 2.0.0 via RVM and it is the only version I had installed on my machine.
Now when I tried to install Rails 4 but got an error saying that I need Ruby 1.9 or higher.
How do I know what version am I really on, and how do I set 2.0.0 as my only version?
On your terminal, try running:
which -a ruby
This will output all the installed Ruby versions (via RVM, or otherwise) on your system in your PATH. If 1.8.7 is your system Ruby version, you can uninstall the system Ruby using:
sudo apt-get purge ruby
Once you have made sure you have Ruby installed via RVM alone, in your login shell you can type:
rvm --default use 2.0.0
You don't need to do this if you have only one Ruby version installed.
If you still face issues with any system Ruby files, try running:
dpkg-query -l '*ruby*'
This will output a bunch of Ruby-related files and packages which are, or were, installed on your system at the system level. Check the status of each to find if any of them is native and is causing issues.
Run this command:
rvm get stable --auto-dotfiles
and make sure to read all the output. RVM will tell you if something is wrong, which in your case might be because GEM_HOME is set to something different then PATH.
The ruby version 1.8.7 seems to be your system ruby.
Normally you can choose the ruby version you'd like, if you are using rvm with following. Simple change into your directory in a new terminal and type in:
rvm use 2.0.0
You can find more details about rvm here: http://rvm.io
Open the website and scroll down, you will see a few helpful links. "Setting up default rubies" for example could help you.
Update:
To set the ruby as default:
rvm use 2.0.0 --default
If you have access to a console in the context you are investigating, you can determine which version you are running by printing the value of the global constant RUBY_VERSION.

Vanishing Ruby Gems

I'm using Ubuntu 8.10 and I installed Ruby and Ruby on Rails following the directions on this site. The exact directions I followed are no longer there as it appears the rubyonrails.org wiki has changed recently. But I installed it the long way. Installed Ruby, then Gems, then installed Rails using "gem install rails".
I haven't really messed with Rails for a while, and I tried to use the Gem command today and...
The program 'gem' can be found in the following packages:
* rubygems1.8
* rubygems1.9
Try: sudo apt-get install <selected package>
bash: gem: command not found
That's just weird to me because I installed rails using the gem command. I have been seaching my computer for the gems binary so I could create a link to it in the bin directory but I can't find it. I know it's installed becaues when I run 'script/server' and go to localhost:3000 in a browser I get the following version information:
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.3.1
Rails version 2.2.2
Active Record version 2.2.2
Action Pack version 2.2.2
Active Resource version 2.2.2
Action Mailer version 2.2.2
Active Support version 2.2.2
Anyone know how I can get my gem command working again? Thanks for any help.
Note: I am new to Rails and fairly new to Ubuntu and Linux in general.
Did you install rubygems from apt-get? If yes, maybe you should try to remove it and install it from source.
Here is another article on installing Rails on Ubuntu:
http://www.rubyinside.com/how-to-install-a-ruby-18-stack-on-ubuntu-810-from-scratch-1566.html
Essentially, you can install Ruby from apt-get or source, but it's recommended to install rubygems from source.
You could look to see if it's in:
/usr/bin/gem1.8
if it is, then symlink /usr/bin/gem to it:
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
BTW, here's another tutorial on how to install rails on Ubuntu 8.10:
http://articles.slicehost.com/2009/1/6/ubuntu-intrepid-ruby-on-rails

Resources