fespinozacast
fespinozacast

Reputation: 2494

ERROR -- : uninitialized constant Airbrake (NameError)

I'm working on a rails 3.2.8 project, I've just installed the airbrake gem to track errors, In development I did the airbrake installation steps, then when I did the deployment with capistrano, I got the following error in the unicorn production log:

E, [2012-10-16T03:02:51.588084 #3645] ERROR -- : reaped #<Process::Status: pid 3846 exit 1> worker=3
I, [2012-10-16T03:02:51.588434 #3645]  INFO -- : worker=3 spawning...
I, [2012-10-16T03:02:51.708539 #3858]  INFO -- : worker=3 spawned pid=3858
I, [2012-10-16T03:02:51.708986 #3858]  INFO -- : Refreshing Gem list
E, [2012-10-16T03:02:52.793217 #3849] ERROR -- : uninitialized constant Airbrake (NameError)
/home/ubuntu/apps/nimrod/releases/20121011033552/config/initializers/airbrake.rb:1:in `<top (required)>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `block in <class:Engine>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/ubuntu/apps/nimrod/releases/20121011033552/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `eval'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `block in builder'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `call'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `build_app!'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:569:in `init_worker_process'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:589:in `worker_loop'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:487:in `spawn_missing_workers'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:498:in `maintain_worker_count'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:272:in `join'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/bin/unicorn:19:in `load'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/bin/unicorn:19:in `<main>'

I've noticed the airbrake gem is installed in shared/bundle/ruby/1.9.1/gems with all other gems.

In production I'm running a Ubuntu 12.04 x64 with unicorn running with nginx and ruby 1.9.3-p194, with this gems

Using airbrake (3.1.4) 
Using capistrano (2.12.0)    
Using bundler (1.1.4) 
Using rails (3.2.8) 
Using unicorn (4.3.1) 

And also tried to stop nginx, unicorn and then start them all again, but it didn't worked

I hope someone can help me with this

Upvotes: 8

Views: 2145

Answers (3)

Tom Maeckelberghe
Tom Maeckelberghe

Reputation: 1999

For me restarting the server this way helped:

cap <env> deploy:stop
cap <env> deploy:start

Upvotes: 0

Luke Exton
Luke Exton

Reputation: 3676

Similar to knagode above. I needed to add the rake handler.

require 'airbrake/rake_handler'

I also needed to stop and start the server again.

cap <env> deploy:stop
cap <env> deploy:start

It didn't seem that the restart functionality picked it up.

My stack:

  • Nginx
  • Unicorn
  • Rails 4
  • Sidekiq
  • Redis
  • Postgres

Upvotes: 1

knagode
knagode

Reputation: 6135

I had similar error after updating my bundle.

It seems like you have to require rake_handler in your airbrake initializer (config/initializers/airbrake.rb or config/initializers/errbit.rb):

require 'airbrake/rake_handler'

Upvotes: 1

Related Questions