Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Rails3 application named 'Test' fails webrick with uninitialized constant Rack::Test::Application

#3872

Webrick fails with rescue in load_missing_constant': uninitialized constant Rack::Test::Application (NameError) if application is named 'Test'. Stack trace:


moe@ingrid:/tmp/Test$ rails server
=> Booting WEBrick
=> Rails 3.0.0.beta application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:456:in `rescue in load_missing_constant': uninitialized constant Rack::Test::Application (NameError)
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:452:in `load_missing_constant'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:91:in `const_missing_with_dependencies'
    from config.ru:4:in `block in '
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1:in `'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:35:in `eval'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:35:in `parse_file'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/server.rb:113:in `app'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/server.rb:189:in `wrapped_app'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/server.rb:155:in `start'
    from /var/lib/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands/server.rb:49:in `start'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/server.rb:83:in `start'
    from /var/lib/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/commands.rb:39:in `'
    from /tmp/Test/script/rails:10:in `require'
    from /tmp/Test/script/rails:10:in `'

I guess this should be somehow mentioned at docs...

Reported by MOE · February 6th, 2010 @ 06:05 AM

State: committed
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. MOE
    MOE
    • Tag set to rails 3.0, rack, server, webrick

    February 6th, 2010 @ 06:22 AM

  2. José Valim
    José Valim

    Could you please provide a patch to update the docs then? Thanks.

    February 6th, 2010 @ 10:05 AM

  3. Kieran P
    Kieran P

    It might be worth adding a check to see if the constant is already defined in the current app, i.e.

    raise "Already used" if defined?(APP_NAME)
    

    February 6th, 2010 @ 06:53 PM

  4. José Valim
    José Valim

    It's more complicated than that. In this case, it's failing due to Rack::Test. And defined?(Test) wouldn't get it.

    February 6th, 2010 @ 06:56 PM

  5. Kieran P
    Kieran P
    • Title changed from Rails3 application named 'Test' fails webrick with uninitialized constant Rack::Test::Application to [PATCH] Rails3 application named 'Test' fails webrick with uninitialized constant Rack::Test::Application

    Right, but checking to make sure things like String or Module aren't used would be a good start.

    I've attached a patch +tests to do this.

    February 6th, 2010 @ 07:58 PM

  6. ecleel
    ecleel
    • Tag changed from rails 3.0, rack, server, webrick to rails 3.0, rack, server, thin

    Thin webserver gives me same problem.

    thin -v = 1.2.7

    March 4th, 2010 @ 11:14 PM

  7. ecleel
    ecleel
    • Tag changed from rails 3.0, rack, server, thin to rails 3.0, rack, server, thin, webrick

    March 4th, 2010 @ 11:14 PM

  8. José Valim
    José Valim
    • Milestone cleared.
    • Assigned user set to José Valim

    March 5th, 2010 @ 07:09 AM

  9. José Valim
    José Valim
    • State changed from new to committed

    Thanks Kieran. Committed.

    March 12th, 2010 @ 08:25 PM

  10. Repository
  11. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM