読者です 読者をやめる 読者になる 読者になる

manatee-itの備忘ログ

プログラム初心者のブログ。ruby on railsでWebサービスを作成中。(仕事が忙しくなかななか進まず) つまずいた所をなんでも記録。 環境:Ruby2.1 + Rails4.1.1 + Passenger + CentOS6.4(Apache + sqlite/MySQL)

nokogiriのエラー

環境:Ruby2.1 + Rails4.1.1 + Passenger + CentOS6.4(Apache + sqlite/MySQL)

nokogiri (1.6.2.rc2)を利用したタスク実行時にエラーが発生した。

-----------------------------------------------------------------------------------

Rakeタスク実行

# rake search:generate

rake aborted!

LoadError: cannot load such file -- nokogiri/nokogiri

/var/www/html/remindertv/lib/tasks/search.rake:8:in `block (2 levels) in <top (required)>'

LoadError: cannot load such file -- nokogiri/2.1/nokogiri

/var/www/html/remindertv/lib/tasks/search.rake:8:in `block (2 levels) in <top (required)>'

Tasks: TOP => search:generate

(See full trace by running task with --trace)

-----------------------------------------------------------------------------------

クラス実行

# rails runner Tasks::SearchTask.execute
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
from /usr/local/lib/ruby/2.1.0/nokogiri.rb:29:in `rescue in <top (required)>'
from /usr/local/lib/ruby/2.1.0/nokogiri.rb:25:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
from /usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
from /var/www/html/remindertv/lib/tasks/search_task.rb:8:in `execute'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/runner.rb:62:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/runner.rb:62:in `eval'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/runner.rb:62:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:128:in `require'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:128:in `require_command!'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:95:in `runner'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

-----------------------------------------------------------------------------------

Gemfileファイルに以下を追加して、bundle installを実行して対応した。

gem 'nokogiri'

 

Gemパッケージのインストールとか全然知らないのだけど、普通に必要な設定のようだ。