Question

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?

Was it helpful?

Solution

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 sam@newrelic.com.

Thanks!

OTHER TIPS

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"] %>

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!

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top