Rails server won't start because of new relic error
Asked Answered
S

4

12

When I try to start my Rails server, I am getting the following error:

I am using ruby 1.9.2

 => Booting WEBrick 
 => Rails 3.1.8 application starting in development on http://0.0.0.0:3000
 => Call with -d to detach
 => Ctrl-C to shutdown server
/Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/agent/agent.rb:318:in `log_app_names': undefined method `join' for nil:NilClass (NoMethodError)
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/agent/agent.rb:439:in `start'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/control/instance_methods.rb:95:in `start_agent'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/new_relic/control/instance_methods.rb:83:in `init_plugin'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/newrelic_rpm-3.4.2/lib/newrelic_rpm.rb:36:in `block in <class:Railtie>'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:30:in `run'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:54:in `each'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/application.rb:96:in `initialize!'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.1.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/toptier/Desktop/Proyectos/CursoIngles/config/environment.rb:5:in `<top (required)>'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `require'
from /Users/toptier/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `block in require'

It is using the following gem: newrelic_rpm (3.4.2). If I comment newrelic line in gemfile it works well,

Any idea?

Statuette answered 8/9, 2012 at 20:46 Comment(1)
I have the same problem with new version of new relic gem 3.4.2. Don't know what causes this, but with 3.4.1 everything works perfect. Try to downgrade gem version.Clawson
N
10

I work at New Relic and we've tracked down the problem.

This happens when nil is explicitly set as the app name, which typically happens for local development of heroku apps that pull their app name from ENV["NEW_RELIC_APP_NAME"]. Since this environment variable is not typically set on your local dev box it comes into the agent's config as nil and crashes the local server. It doesn't effect deployed versions of the app where this variable is set.

Obviously the agent should handle this case gracefully, and we'll have a patch out in the next day or two. We just completed a major refactoring of the agent's configuration, and this edge case was missed in our internal testing.

etoleb gives a good workaround in the comment. We're very sorry for causing you this headache.

If you have any questions or concerns feel free to email me directly at [email protected].

Thanks!

Navada answered 10/9, 2012 at 22:37 Comment(2)
Thanx, guys. Looking forward to your patch to upgrade newrelic gem.Clawson
I get this deploying to Heroku. The app deploys, but the error shows up in the deploy console. Just FYIParfitt
S
3

The issue seems to be related to the app_name setting being blank in your newrelic config. Personally I went through the Heroku installation (so your config may look different) but this is what I did:

Within config/newrelic.yml (copied from https://gist.github.com/2253296) I removed the line

  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>

from the common config (line 35 for me) into the production config (after line 247 for me), which winds up looking like

production:
  <<: *default_settings
  monitor_mode: true
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
Spock answered 10/9, 2012 at 19:15 Comment(0)
N
3

Great to see a reply from someone who can take responsibility! Nice work, New Relic. Thanks, @samg.

Since the issue is just a nil env value, rather than downgrading the gem or diddling with config files, I just added the environment variable.

It's easy to see what the setting is on heroku:

$ heroku config
  ...
NEW_RELIC_APP_NAME:    my_app_name
NEW_RELIC_ID:          123456
NEW_RELIC_LICENSE_KEY: 982987ae987987af98798something7e897987987c7b9d7
NEW_RELIC_LOG:         stdout
 ...

I then opted to set a local env var via my project's .rvmrc file, where I so some other similar things:

rvm use ruby-1.9.2-p290@ConTracker --create
export PATH=bin:$PATH
export NEW_RELIC_APP_NAME=my_app_name

Then it just took a cd .. and a cd back in to my project, and it was working with the gem on version 3.4.2.

Party on!

Nitrochloroform answered 11/9, 2012 at 5:39 Comment(0)
S
1

Thanks for the comment. The answer is to downgrade to 3.4.1.

Statuette answered 8/9, 2012 at 21:13 Comment(1)
an answer is to downgrade. ;] A few other options are presented here. I found it easiest to just set a local env var for what was missing.Nitrochloroform

© 2022 - 2024 — McMap. All rights reserved.