nikhaldi / exception_notification-rake

Sends mail upon failures in Rake tasks
MIT License
39 stars 14 forks source link

Rails 4.1 and exception_notification-rake gem causing uninitialized constant ExceptionNotification #6

Closed DaniG2k closed 10 years ago

DaniG2k commented 10 years ago

Hello, I'm not 100% sure this is a bug in exception_notification-rake but I have a feeling it might be, so I'll post the issue I'm having here: http://stackoverflow.com/questions/22959711/rails-4-1-and-exception-notification-rake-gem-causing-uninitialized-constant-exc

I get an uninitialized constant ExceptionNotification (NameError) when trying to start up the Rails server after an upgrade to Rails 4.1

Cheers!

nikhaldi commented 10 years ago

I haven't tested the gem with Rails 4.1 yet, it's possible something changed there from 4.0. But the error seems to imply you don't have the exception_notification gem (which is a dependency of exception_notification-rake). Did you do a "bundle update"? Can you check in your Gemfile.lock what versions of the exception_notification and exception_notification-rake gems you have?

DaniG2k commented 10 years ago

Hello nikhaldi, yes I have the gem installed already:

Cheers

DaniG2k commented 10 years ago

The latest suggestion I got from stackoverflow says that a potential fix for this would be to make exception_notification 4.1.0.rc a dependency, as this latest version should work with Rails 4.1

nikhaldi commented 10 years ago

Your findings from stackoverflow are correct. I just pushed a version 0.2.0.rc1 with updated dependencies tracking exception_notification 4.1.0.rc1: https://rubygems.org/gems/exception_notification-rake/versions/0.2.0.rc1

This version should work with Rails 4.1. I'll push a non-rc version once exception_notification does the same. Let me know if there are still problems.

nathanvda commented 10 years ago

:+1:

DaniG2k commented 10 years ago

I still seem to be having issues with this. Added gem 'exception_notification-rake', '~> 0.2.0.rc1' to my Gemfile and ran bundle. When I try to run the Rails server, I get the following:

/Users/DaniG2k/myapp/config/environments/development.rb:25:in 'block in <top (required)>': undefined method '[]' for nil:NilClass (NoMethodError) from /Users/DaniG2k/.rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/railtie.rb:210:in 'instance_eval' from /Users/DaniG2k/.rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/railtie.rb:210:in 'configure' from /Users/DaniG2k/.rvm/gems/ruby-2.1.1/gems/railties-4.1.0/lib/rails/railtie.rb:182:in 'configure' from /Users/DaniG2k/Documents/Aptana Studio 3 Workspace/myapp/config/environments/development.rb:

I think this might have to do with the fact that Rails 4.1 became more strict with casting Activerecord objects to arrays first? Might be wrong :P

nathanvda commented 10 years ago

Check line 25 of environment/development.rb. You are referring something that is (no longer?) there. Also: please format your dumps correctly (as code). Now it is not legible.

If I count correctly in your SO question, that is this line (my psychic skills are of the charts) :grinning:

 :user_name  =>  Rails.application.secrets.email['user'],

you should check your secrets.yml, you could easily test that in your rails console (if you comment this block for now). This is no longer related to exception notification.

DaniG2k commented 10 years ago

That line seemed to be fine. I'm getting the original error again now though:

/development.rb:59: in 'block in <top (required)>': uninitialized constant ExceptionNotifier::Rake (NameError)

:unamused:

nathanvda commented 10 years ago

I see you are thinking: he used his psychic skills before, so he will know by heart what is on line 59 anyway, no need to show it. Let him guess, we should not make this toooooo easy for these guys.

But you should be more careful interpreting your error messages: that it is not the original error, now you can't find the exception-notification-rake (and before it was exception-notification). Details matter.

I see the code of this gem supports both ExceptionNotifier::Rake and ExceptionNotification::Rake, and I see the original ExceptionNotification also uses both namespaces (I thought they stopped using ExceptionNotifier), so I have no idea. Might try writing ExceptionNotification::Rake instead, see if it makes a difference. But probably @nikhaldi should say something smarter :)

DaniG2k commented 10 years ago

Ok got it to work. When I was tinkering with the Gemfile I had removed (and forgotten to place back) the line gem 'exception_notification-rake', '0.2.0.rc1'. All good now, working :smile: thanks guys