Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

Monday, November 19, 2012

Uninstalling Ruby on Rails in Ubuntu Manually

Only do this if you installed RoR from Source.

It's playtime! Last week, I blogged how I was able to successfully install RoR from source despite several issues encountered. Now, I'm going to uninstall RoR manually. Most of you might think my previous adventure rendered some of my screws loose. Perhaps a little (hehe) but I assure you everything I type here is thoroughly tested so proceed at your own risk. ;)

I reason I have the guts to do crazy stuff is because I'm running Ubuntu in VM so I don't care much if I wreck numerous instances (which I did for the entire duration of my RoR installation journey) because I could easily reinstall Ubuntu. But this action has become tiring and very annoying. I admit I'm a newbie at both Ubuntu and Ruby and I'm doing this for educational purposes only. It's hitting two birds with one stone: I learn how to use Ubuntu (the terminal commands stuff) while experimenting on RoR installation.


According to Ruby homepage, there's three ways to install Ruby:

1) Compiling from Source 
    - We're done with this option.

2) Using third party tools (like rvm and rbenv)
    - I'm planning to use rvm for my next RoR installation attempt. If I'll have some spare time I might also use rbenv and maybe I'll do a post about which of the two is easier to use from a total beginner's perspective. Don't hold your breath though.

3) Using package management systems (like apt-get, aptitude and yum)
    - I'd read several articles/posts that warns against using this option (Ryan Bigg's guide comes to mind). I'm not going to push my luck and I'm going to follow their advice and be a good girl. After all they know what they're saying right?

This also translates that there are also three ways to uninstall Ruby: manually (refer to post below), using rvm (rvm uninstall version_number) and using apt-get (sudo apt-get purge ruby).



Without further ado, let's start.

The sequence we installed RoR last time was Ruby + RubyGems + Rails. We're going the opposite way in uninstalling: Rails (with dependencies) first, then RubyGems and Ruby.


To uninstall Rails + all dependencies:

gem list --no-version | xargs sudo gem uninstall -ax

I got this one-liner from James McGrath's post. If you want to know the meaning for each switch used, he explained it very well in his post.


To uninstall all gems except for one:

gem list --no-version | grep -v rails | xargs sudo gem uninstall -ax

This will uninstall all gems (Rails dependencies and other gems installed) except for Rails (remember Rails is also a gem).


To delete only the old versions:

gem clean


To uninstall specific gem:

sudo gem uninstall rails

This will uninstall Rails gem only.


To uninstall RubyGems and Ruby (in one sweep):

sudo rm /usr/local/bin/{ruby,irb,gem,testrb,erb}
sudo rm /usr/local/lib/libruby-static.a
sudo rm -r /usr/local/lib/ruby/


To check:

whereis ruby
whereis gem


Tuesday, November 13, 2012

Solution to “ruby installation is missing psych” Error

To save yourself from this headache, install yaml first before installing Ruby. 


I'm still trying to install Ruby on Rails on Ubuntu 12.04 and I got this warning after I installed RubyGems:

It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby.

I googled this error and it seems several people had this problem too. A bug??? Yep. (If you're installing Ruby from rvm, refer to thisthis and/or this) Unfortunately, their solutions won't work for me because I'm installing Ruby from source not from rvm. So I decided to follow the instruction please install libyaml and reinstall your ruby and prayed it'd work.

I installed libyaml:

tar -xvzf yaml-0.1.4.tar.gz
cd yaml-0.1.4/
sudo ./configure && sudo make && sudo make install

Then "reinstalled" Ruby from Source:


wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar -xvzf ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327/
sudo ./configure && sudo make && sudo make install

When I typed gem -v, I still got the same error. :( I googled for the error and found this SO answer as my saving grace.

I recompiled yaml module:

cd ruby-1.9.3-p327/ext/psych
sudo ruby extconf.rb
sudo make && sudo make install

Judgement time. *drum roll*  To test, I typed gem -v

Aaaaaaaaaannnnnndddddd no error. I got my gem version: 1.8.24. Yipee. :)

Sweetness... 


A little explanation for myself (and to others who are curious):
## recompiles yaml or any other module
cd ruby-1.9.3-p327/ext/<module folder>
sudo ruby extconf.rb

## reinstall Ruby
sudo make && sudo make install