infundibulum

Installing Rails (with readline and console support) on Ubuntu LTS

January 27th, 2007

Here’s what I had to do to get Ruby on Rails to run on Ubuntu LTS with a functioning console (and irb).

(By the way, Wordpress has kind of borked up the formatting of this post, there’s a plain version at:

http://ruphus.com/code/rails/railsonubuntu-howto.html

It comes down to:

  1. Random stuff
  2. Ruby (from source)
  3. Mysql packages
  4. Rubygems (from source)
  5. Rails (from a gem)

Building on posts by:

Thanks guys.

Preliminaries

Mostly via Ed Howland’s post (I believe termcap-compat, which he lists, is no longer necessary, since libc is up to 6 or uh erm… well I don’t rightly know, but that package wasn’t in the repos and everything seems to work for me without it! ☻).

sudo apt-get install gcc 
sudo apt-get install build-essential 
sudo apt-get install bison byacc gperf 
sudo apt-get install zlib1g-dev 
sudo apt-get install libreadline5 libreadline5-dev 
sudo apt-get install libncurses5 libncurses5-dev  
sudo apt-get install libssl-dev 

Build Ruby

Download the Ruby source:

wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5-p12.
tar.gz tar xzf ruby-1.8.5-p12.tar.gz 

And build it. Make some coffee, this takes a while. ☻

cd ruby-1.8.5-p12 ./configure make sudo make install 

Not sure why this is necessary (ActionMailer?)

apt-get install postfix 

You’ll also want Ruby’s documentation stuff:

sudo apt-get install  rdoc ri irb 

Mysql packages

apt-get install mysql-server mysql-common mysql-client libmysqlclient15-dev libmysqlclient15off 
apt-get install libmysql-ruby1.8 

Build Ruby Gems

We’ll be using this to install Rails:

wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz 
tar xzf rubygems-0.9.0.tgz cd rubygems-0.9.0 
sudo ruby setup.rb 

Build Rails

Actually the easiest part, I’ve never had trouble with this (knock wood).

sudo gem install rails --include-dependencies 
sudo gem install mysql 

Note that the mysql gem is really the DB connector for Ruby; it’s not Mysql itself. (We already did that.)

Afterword

Now that I’ve explained what worked for me, let me explain the problem I had, in case you’re interested or facing the same problem.

When I originally followed the steops in Richard Crowley’s post, everything seemed to install fine and Rails worked great.

But I found that my console wouldn’t work, just like Paul Ingles:

Loading development environment.
/usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require':
 no such file to load -- readline (LoadError)     
 from /usr/local/lib/ruby/1.8/irb/completion.rb:10     
 from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'     
 from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'     
 from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'     
 from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'     
 from /usr/local/bin/irb:13 

This means no readline in irb, and no script/console whatsoever, which I gotta have.

So I tried his solution, which consisted of building readline from source, and then building Ruby. I’m not totally positive (though I’m going to find out soon when I rerun this whole process on my laptop), but I think that the steps I’ve described above obviate building readline from source on Ubuntu.

And now this works! \o/

./script/console 

Leave a comment!

I’d really appreciate comments about this process, especially corrections or simplifications.

I’d also just like to get in touch with other folks running Rails on Ubuntu! Believe it or not not everybody using Rails is on OSX. ;-)

Comments

  1. 1

    I had the same problem with script/console in kubuntu. I thought that your solution was a bit lengthy. So, after further search I found a couple of links that solved the problem in a simpler manner. Check them out:
    http://ubuntuforums.org/showthread.php?t=169891
    http://blog.nanorails.com/articles/2006/03/06/installing-readline-on-kubuntu

    Steps that worked for me:
    1.) Download ruby source.
    Download Here
    2.) Extract the tar file.
    tar -xvf ruby-1.8.5-p12.tar.gz
    3.) Change to that directory
    cd ruby-1.8.5-p12.tar.gz
    4.) Type these commands.
    ./configure
    make
    sudo make install
    5.) Install readline and ncurses.
    apt-get install libncurses5-dev libreadline5-dev
    6.) go back to the folder ruby source folder.
    ruby-1.8.5-p12.tar.gz
    7.) Type these commands
    cd ext
    cd readline
    ruby extconf.rb
    make
    sudo make install

    Thats it. The console bug no longer appears.

    - ror-fan @
  2. 2

    Do you have ruby 1.8 installed twice? “apt-get install ri” etc finds that I don’t have ruby 1.8 package installed (because I have installed 1.8.5 from source) and wants to install it.

    Currently I have severely borked rails 1.2.2 installation (every attempt to use rails apart from -v gives an error “undefined method `write_inheritable_attribute’”) and I’m trying to figure out what went wrong.

    Ruby 1.8.5 in /usr/local seems to be ok. I can install rails/mysql etc gems. This all started when I had an existing ruby 1.8.4 and 1.2.1 rails installation but wanted to upgrade to 1.8.5. Baaaaad move.

    - LadyBug @
  3. 3

    Just a side comment on my problem. It seems that while rails/gems/ruby were installed ok, the rails dependencies were somewhat mangled. So, gem uninstall/install activesupport/activerecord/etc helped a lot.

    At least webrick runs now, but my application still doesn’t.

    - LadyBug @
  4. 4

    Hi peeps,

    I am just pasting some notes I have made that may be helpful! The notes are not complete but my offer a clue or two.

    ————————————————–

    How to install a rails stack on Ubuntu Dapper Drake.

    # This quick guide makes the following assumptions:
    # You are familiar with Ubuntu server and file directories.
    # You are aware of creating users and keys.
    # You are aware of Linux security measures.
    # ‘\’ = part of the previous line (cat).

    1. “Uncomment out unviverse packages. etc/apt/sources.list”

    # When building Ruby and Rubygems from source, some libraries are needed.
    # This is when we use apt-get to install the libraries we need.

    2. “apt-get update”
    3. “apt-get install build-essential”
    4. “apt-get install bison byacc gperf
    apt-get install zlib1g-dev
    apt-get install libreadline5 libreadline5-dev
    apt-get install libncurses5 libncurses5-dev
    apt-get install libssl-dev”

    # Alternatively step 4 may be combined, as below:

    “apt-get install bison byacc gperf zlib1g-dev libreadline5 \
    libreadline5-dev libncurses5 libncurses5-dev libssl-dev”

    5. “wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz”
    “tar xzvf ruby-1.8.6.tar.gz”
    “cd ruby-1.8.6″
    “./configure && make && make install”
    6. “wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz”
    “tar xzvf rubygems-0.9.2.tgz”
    “cd rubygems-0.9.2″
    “ruby.set.rb”
    7. “rm -rf ruby*”

    # We do not include Rails rdoc. This saves production system resources.

    8. “sudo gem install rails –include-dependencies –no-rdoc –no-ri”

    # Now we install MySql

    9. “apt-get install mysql-server-5.0 mysql-client-5.0 \
    libmysqlclient15-dev libmysqlclient15off zlib1g-dev libmysql-ruby1.8″

    # Install the mysql/Ruby binding
    “sudo gem install mysql”

    # make sure you have irb ‘require’ rubygems. The easy way (so far) is
    # create a file ‘.irbrc’ in /etc/.irbrc
    “nano .irbrc”

    # In your .irbrc file put the following –
    “require ‘rubygems”

    - MichaelT @
  5. 5

    Thanks for the follow-up there Michael, amazingly I still got something out of that 2 years down the line with a related issue.

    - WC @
  6. 6

    Welcome to visit our sale puma shoes online shop! Our online shop is one of the most popular online shops in China! We can offer the best service and the best quality puma trainers for you! They are different styles and colors!all of our authentic handbags have a very high quality and sale puma shoes at a very low price! They are all this years new styles and at the head of fashion!Welcome your coming and enjoy shopping Puma Speed Cat Shoes.

    - salepumashoes123 @
  7. 7

    Methodenmann

    - Methoden Mann @
  8. 8

    Life just like shoes at our feet. Only wear comfortable, it can help to move forward for you. Believe me, if you want to achieve something in life, you need a pair of good shoes. Our website [url=” http://www.airyeezy.net /”] [/url] provides cheaper but high-quality shoes, hope you like it.

    - nike air yeezy @
  9. 9

    You could find a number of deals in prom dresses and buying cheap prom dresses are the best way to get through the range of women dresses for prom. Prom dresses and cheap prom dressesare available online for all occasions.

    - Beauty @
  10. 10

    So good topic and do you like Mbt Shoes.MBT shoes are good quality and free choose from http://www.antimbt.com/ !!!
    Now you order from www.antimbt.com you can enjoy our Promotion policy:
    - Order 2 pairs one-time, enjoy 10$ discount, discount coupon number is:
    2salepumashoes.com
    - Order 3 pairs one-time, enjoy 20$ discount, discount coupon number is:
    3salepumashoes.com
    - Order more than 3 pairs one-time, you can enjoy the wholesale price, order
    more get more discount!
    ALL Puma Shoes from http://www.salepumashoes.com/ ,PUMA Shoes,puma sandals all cheap puma shoes supply for you!
    Please contact me free,if you have any time questions,our msn: salepumashoes@msn.com ,our email:sales@antimbt.com.We will sincerely service for you!
     

    - puma trainers @
  11. 11

    Every girl will be happy with inspired links of London which make her look dazzling and outstanding; every girl will be happier to obtain sweetie braceletswith less money which makes them a sense of achievement. That’s why girls all like links of london charms where various links of silver charms are at most keen prices.charm bracelets

    - silver charms @
  12. 12

    Justin Bieber Shoes is very popular all over the world.It is very comfortable to your foot with a cheap supra shoes.In our website you can find:supra skytop,justin bieber shoes,supra shoes philippines. supra tk society shoes have arrived,why not to choose for you.

    - justin bieber shoes @
  13. 13

    efox-shop the best place to buy dual SIM dual standby phone. The efox-shop service is good, and the full range, such as chinesische handy kaufen china handy kaufen Großhandel Handy Grosshandel Handy Großhandel Handys chinesische handy TV Handy Chinesische Handys welcome to purchase http://www.efox-shop.com chinesische handy kaufen china handy tv handy Chinesische Handys

    - china handy @
  14. 14

    P90x workout : weblog p90x workout p90x workout in many of the product, the rosetta stone spanish is one of the most popular, the reason is very. Fitness P90x Reviews dvd insanity workouts ,beachbody p90x,rosetta stone p90x workout dvd insanity workout dvd rosetta stone brazil butt P90x workout lift fitness dvdsrosetta stone language level insanity set with audio insanity workout companion us.

    - insanity workout @
  15. 15

    Pregnancy is an exciting time full of hope Abercrombie and Fitch and excitement. It can also be an overwhelmingly Abercrombie self-conscience time as well, as your body is pregnant Abercrombie Sale

    - Abercrombie @
  16. 16

    Why we choose MBT? Because MBT is completely different with many other shoes. MBT is very particular, it has a positive on the entire body, not just the feet. MBT shoes actives muscle tissue instead of undermining all of them. It is unstable, not stable. The only is curved, not flat.

    - mbt shoe @
  17. 17

    “Love is not a thing to understand.
    Love is not a thing to feel.
    Love is not a thing to give and receive.
    Love is a thing only to become
    And eternally be. .”

    - moncler store @
  18. 18

    I absolutely have enjoyable reading your blog. dont stop posting the excellent quality info!
    MBT SHOES
    MBT Womens Boots
    MBT Womens Shoes
    MBT Mens Sandals
    MBT Mens Shoes

    - mbt shoes @
  19. 19

    We wholesle many styles of bodybuilding.They are very comfotable and easy to macth with all kinds of clothes.
    We wholesle many styles of bodybuilding.They are very comfotable and easy to macth with all kinds of clothes.
    [url=http://blog.bodybuilding.com/]bodybuilding[/url] are very suitable for men who like doing sport.

    - bodybuilding @
  20. 20

    HELLO,everyone. If you want to search the MBT shoes, please click below
    MBT SHOES
    MBT Womens Boots
    MBT Womens Shoes
    MBT Mens Sandals
    MBT Mens Shoes

    - mbt womens sandals @

Leave a Reply