CentOSにてreadline-develが入っていないと、rails consoleの実行で以下のようなエラーになります。
[bash gutter=”0″]
$ rails console
/usr/local/rbenv/versions/2.1.2/lib/ruby/2.1.0/irb/completion.rb:9:in `require’: cannot load such file — readline (LoadError)
from /usr/local/rbenv/versions/2.1.2/lib/ruby/2.1.0/irb/completion.rb:9:in `’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands/console.rb:3:in `require’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands/console.rb:3:in `’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands/commands_tasks.rb:128:in `require’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands/commands_tasks.rb:128:in `require_command!’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands/commands_tasks.rb:59:in `console’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands/commands_tasks.rb:40:in `run_command!’
from /usr/local/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.1.2/lib/rails/commands.rb:17:in `’
from bin/rails:4:in `require’
from bin/rails:4:in `’
[/bash]
yumでインストールしてもよいですが、ここではrb-readlineのGemにて解決しましょう。
まず、Gemfileに以下を記述します。
[bash]
gem ‘rb-readline’
[/bash]
インストールを実行して、
[bash gutter=”0″]
$ bundle install
[/bash]
再度、rails consoleを実行します。
[bash gutter=”0″]
$ rails console
Loading development environment (Rails 4.1.2)
irb(main):001:0>
[/bash]
これでOKです。
ピンバック: 一からはじめるRoRoBoW(前編) | IT技術情報局