Ubuntu | Ruby - Can't Remove Ruby 1.9.2 from system - ruby

I'm new to ubuntu, and might have had a couple of
false starts updating ruby / rails. I'm trying
to start clean by removing all versions of every
thing ruby from my system
I think I've installed everything through either
Synaptic, or aptitude purge, but I can still do the
following:
jwally#jwally-laptop:~$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
jwally#jwally-laptop:~$ gem -v
1.3.7
jwally#jwally-laptop:~$ irb
irb(main):001:0> RUBY_VERSION
=> "1.9.2"
but when I type "dpkg -l | grep ruby,
I only get the following:
rc ruby1.8-elisp 1.8.7.249-2 ruby-mode for Emacsen
thanks in advance

You may have installed an instance of Ruby without using Ubuntu's package system. Try:
which ruby
If this yields something other than /usr/bin/ruby (such as /usr/local/bin/ruby), then this is the case. Ubuntu can't uninstall locally installed stuff. You need to do that manually.

To see which package ruby is owned by run:
dpkg -S `which ruby`
If it can't find the package, then Ruby was installed outside of the Ubuntu package manager. You'll have to remove it manually.
I'll once again recommend this blog post for instructions on the best way to install Ruby on Ubuntu: Ubuntu, Ruby, RVM, Rails, and You.

Related

Ubuntu not using RVM ruby version

I"m using Ubuntu and RVM. I've run the command
rvm use 2.1.2
Running
ruby -v
gives me the 2.1.2 version.
When I start rails I get the following error
Your Ruby version is 2.3.1, but your Gemfile specified 2.1.2
But RVM doesn't even have 2.3.1 installed.
You may have apt installed ruby. For example, when I run apt show ruby, on my system, I get this
$ apt show ruby
Package: ruby
Version: 1:2.3.0+1
Priority: optional
Section: interpreters
Source: ruby-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
...
Clearly, the ruby version is 2.3.x here. So I suggest you apt remove ruby first. If that doesn't solve the problem, it is possible that there is a problem with your $PATH environment variable.
ruby -v gives you the ruby version installed on your system, not the current ruby version used by RVM.
To see which ruby version is currently used by RVM, use rvm list. Make sure it's using ruby version 2.1.2 by running rvm use ruby-2.1.2
From your question, it seems Rails is using your system ruby instead of RVM ruby.

Can't find ruby or gem commands after doing ruby-install in Ubuntu

I have installed ruby 1.9.3 in my Ubuntu 12.04 machine following the instructions in https://github.com/postmodern/ruby-install and executing the following command:
sudo ruby-install ruby 1.9.3
I was assuming this would link from my /usr/bin or somewhere else visible from my path ruby or gem, but it doesn't. When I try for example: gem install bundler, I get:
sudo: gem: command not found
It also can't find ruby when I try ruby -v.
If I install with sudo apt-get install ruby1.9.3, I'm able to execute both ruby and gem:
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ gem -v
1.8.11
I was expecting from ruby-install the same output I got from apt-get. Am I looking in the wrong place? How do I run ruby and gem after installing with ruby-install?
I know there are other installers for ruby like rvm and rbenv, but I'm following some installations instructions and they clearly instruct to use ruby-install.
Thanks in advance!
OK, found the answer.
After running
sudo ruby-install ruby 1.9.3
the last line from the log is:
>>> Successfully installed ruby 1.9.3-p547 into /opt/rubies/ruby-1.9.3-p547
Which I have no excuse for not paying attention to since it's in bold colourfull letters.
Erm, anyway, adding /opt/rubies/ruby-1.9.3-p547 to the PATH makes ruby and gem work.
export PATH=$PATH:/opt/rubies/ruby-1.9.3-p547/bin

How to remove Ubuntu stock Ruby 1.8? Not apt

Ubuntu came with Ruby 1.8 installed, but I really would rather (and need, for rails) 1.9.2. I tried apt-get purge but apt doesn't believe there is a ruby package (however ruby -v keeps returning ruby 1.8).
I have installed rvm but ruby -v now only returns bash: /usr/bin/ruby: No such file or directory. I'm lost, any help?
I removed ruby from /usr/bin but it refuses to accept that rvm exists and keeps suggesting i install the 1.8 or 1.9.1 packages.
RVM is a bit wonky on Ubuntu. Look here for a fix before going any further.
If you have access to a GUI, try running The Synaptics Packet Manager
I had the same problem and Synaptics marked ruby 1.8 as installed. Unchecked the package, clicked on run and ruby was GONE
$ ruby -v now yields command not found
Now you can safely run
$ apt-get install rubyX.X.X
Happy coding!

I'm confused, what's the easiest way to install Ruby 1.9.2 on OS X?

My current version is ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
Step 1. Install Homebrew: https://github.com/mxcl/homebrew
This enables you to install various *IX projects on a mac. You may need to install xcode as part of this, so you may need your OS X disc to hand. Homebrew is useful for many other things - a good thing to have installed anyway.
Step 2. Install Ruby Version Manager:
brew install rvm
Step 3. Install whichever Ruby version you want. This means you can have multiple Ruby installations (with their own sets of rubygems) running independently of one another. for 1.9.2 try this:
rvm install 1.9.2
If you get a 'readline' error, try this:
rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
You should now be able to do this to test your ruby version:
ruby --version
To switch back to another version of ruby, just use the rvm command.
You can try rvm to install whatever the version of ruby.
if you will get error
undefined method `path' for Gem:Module (NoMethodError)
during command
~/rubygems-1.3.7 $ ruby setup.rb
remove ruby and rubygems with command
sudo autoremove ruby
sudo autoremove rubygem
ant try to install all again

Rails 3 on Fedora issues

I have been trying to get Rails 3 installed in Fedora, it requires Ruby to be 1.8.7 or 1.9.2. Fedora official yum repos have Ruby 1.8.6 which is of no use. So I decided to compile it myself from the source, downloaded the source, compiled it and installed it successfully.
But this weird thing happens after the install, sudo gem or sudo ruby are not working, it just returns saying command not found.
which ruby
/usr/local/bin/ruby
ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
sudo ruby
sudo: ruby: command not found
sudo echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
Am I missing something, why doesnt it find ruby when its in the PATH?
check your PATH variable (set in your .bash_profile or .bashrc file, add /usr/local/bin to the front of the PATH:
PATH=/usr/local/bin:$PATH
I'd recommend that you check out RVM -- so far the best way to install and switch between different Ruby versions and to maintain Gems independently for each version!
https://rvm.io
Using RVM is much easier than compiling by hand, and it keeps all your Gems organized by Ruby version!
There's also a RailsCast on it: http://railscasts.com/episodes/200-rails-3-beta-and-rvm

Resources