Ruby on Rails and Ubuntu

Although i have nice Ruby on Rails support at dreamhost, i have decided to install RoR to my local machine. IMHO a local RoR, combined with Radrails and WEBrick is the simplest and quickest solution, usually fully enough for development purposes.

To install Ruby on Rails, you just need to do 3 things:

  1. Install Ruby
  2. Install RubyGems, a package management system for Ruby
  3. Once you have RubyGems installed, it is a piece of cake to install new packages. In this concrete case:

gem install rails –include-dependencies

And you are on rails! This was easy, wasn’t it?

Well, yes, unless you happen to use Ubuntu .

Under Ubuntu, the MySQL-Ruby binding was outdated. No problem, just get the newest mysql-ruby gem:

gem install libmysql-ruby
At this point the trouble begun. Instead of installing the mysql binding, i got every kind of nasty error messages, including:

ERROR:  While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
ruby extconf.rb install mysqlnchecking for mysql_query() in
-lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no

WTH?! I have googled a day to find the problem, then also wrote to the RoR and Ruby mailing lists, but got no answer. As i came to know later, this happened because my problem had nothing to do with Ruby, Rails or MySQL.
After several hours of trying every possibility, i have been checking the last one: Do i have gcc and make on my machine? Well, i did not! I have thought a decent linux distribution should have make, gcc et al – and i was wrong (considering that Ubuntu is a decent distro).

Ubuntu is a very nice distribution, for desktop usage. However, if you are planning to use it for development, compiling etc., double check whether you have basic development tools (apt-get install build-essential), gcc and whatever you may need for compiling/deploying your applications.

Or install Rubuntu

9 thoughts on “Ruby on Rails and Ubuntu

  1. Make sure you have the header files (libmysqlclient…-dev), confirm where your mysql is installed, and then let mysql_config do the rest of the talking for you (it will provide the location of the rest of the necessary files in order to compile):

    gem install mysql — –with-mysql-dir=/usr/bin –with-mysql-config=/usr/bin/mysql_config

  2. Pingback: :!ruby response

  3. Hi, nice post ! I googled here.

    Servel hours previously I have the same problem as yours. I have installed build-essential package yet, but the error still humbled me. I guestimate it’s not because of starved of build-essential package, but ruby1.8-dev instead. You could check out whether you installed ruby1.8-dev before installing build-essential package.

  4. Hi, nice post ! I googled here.

    Several hours previously I have the same problem as yours. I have installed build-essential package yet, but the error still humbled me. I guestimate it’s not because of starved of build-essential package, but ruby1.8-dev instead. You could check out whether you installed ruby1.8-dev before installing build-essential package.

  5. I have the same problem as yours. I install build-essential package, gcc, make, g++, but the error still humbled me. And then i install libmysqclient15-dev. And problem was solved.
    Really usefull post! Thx!

  6. The following commands should fix this issue:

    sudo apt-get install libmysqlclient-dev

    cd /var/lib/gems/1.8/gems/mysql-2.7

    sudo ruby extconf.rb

    sudo make

    sudo make install

  7. whatisit, you’re a star! Googled forever to find the solution and none of the above worked (and I had all the headers etc. installed already) but your suggestion did the trick. Thanks a lot!

  8. Do you have a spam problem on this blog; I also use Blog Engine, and I was speculating about your experiences; we have developed some great techniques and we are looking to exchange practices with others, please Email me if interested.

  9. In a saucepan, saute the green onions in a bit of vegetable broth for a couple of minutes, then add the parsley, zsweet, paprika, salt, dill, thyme, celery seed, and cayenne. What is involved before, during, and after surgery.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>