Wednesday, September 16, 2009

Gem install errors

When installing gems, sometimes you get the following message:

dean@Dean-Ubuntu:~$ sudo gem install mongrel
Building native extensions. This could take a while...
ERROR: Error installing mongrel:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install mongrel
extconf.rb:8:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:8

The quick answer is:

sudo apt-get install ruby-dev

I guess ruby-dev contains the native headers that the finished product "just Ruby..." doesn't have.

Installing Rails on Ubuntu

After install Rails using apt-get, I received the following message:

dean@Dean-Ubuntu:~$ rails -v
getopt: invalid option -- 'v'
Terminating...

This is definitely unusual and not the way rails works on my Mac. I found this blog post, which describes a perfect method for getting rid of the problem. Basically, it seems that it is preferable to install rails using gem, not using apt-get. Go figure...

Installing PostgreSQL

On a Debian Linux distribution such as Ubuntu, you can install postgresql (and a graphical administration tool) by using:

sudo apt-get install postgresql pgadmin3

and it merrily does its thing. It even starts the server for you. However, the default installation of PostgreSQL creates the root user "postgres" with no password. Furthermore, PGAdminIII requires that you enter at least one character in the password field or it complains. Doh!

After having experienced this twice (once in Mac OS X and once in Ubuntu Linux) I thought I'd jot this down for generations of administrators to come. Essentially, this post gives the best description of what to do:

  • Edit the pg_hba.conf file. The post gives the most useful information: the directory in which this file is located! (/etc/postgres...)
  • Instead of "md5", other posters say to change it to "trust". If you're running a dev system like me, "trust" is supposed to have fewer auth checks
  • To get the config changes to stick, restart using "/etc/init.d/postgresql-8.3 restart
  • To change the password, use "psql -U postgres". The master database is the default. psql should be in /usr/bin, which should be in your path
  • The semi-colon in the blog is important. You should get the response, "ALTER ROLE" if it worked properly

Trying to open PGAdminIII again, I was able to give it a non-blank password, which made it really happy.