пятница, 21 декабря 2012 г.

rails 3 rvm console: cannot load such file -- readline

After installing rvm on Ubuntu sometime I have error when I try to go app console:


current$ bundle exec rails c staging
/home/ubuntu/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/completion.rb:9:in `require': cannot load such file -- readline (LoadError)
from /home/ubuntu/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/irb/completion.rb:9:in `'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:3:in `require'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:3:in `'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:38:in `require'
from /var/www/apps/staging/newage/shared/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:38:in `'
from script/rails:6:in `require'
from script/rails:6:in `
'


Solution:

1. rvm requirements

Requirements for Linux "Ubuntu 12.10"

NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
             This is the *original* / standard Ruby Language Interpreter
      'ree'  represents Ruby Enterprise Edition
      'rbx'  represents Rubinius

bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).

To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.

Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
  ruby: /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

# For JRuby, install the following:
  jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
  jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk

# For IronRuby, install the following:
  ironruby: /usr/bin/apt-get install curl mono-2.0-devel

# For Opal, install the following:
  opal: /usr/bin/apt-get install nodejs npm


2.  sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

3.  Install readline:

cd  .rvm/src/ruby-1.9.3-p327/ext/readline

ruby extconf.rb
make
sudo make install


The solution from there: http://stackoverflow.com/questions/4922700/ruby-1-9-2-and-rails-3-cannot-open-rails-console

Good luck!