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.

Why does rack have to be installed as a gem?

#2951

Line 34 of actionpack/lib/action_controller.rb forces rack to be installed as a gem.

Why can't I have rack vendor'd as a normal library (say, in vendor/libs)?

For that matter, if we have to ensure that rack is installed, why not include it with rails, like tzinfo, memcache-client, etc?

Reported by Joe Van Dyk · July 24th, 2009 @ 07:14 PM

State: invalid
Milestone: 3.0.2
Assigned to: Matt Jones Matt Jones
Importance: Medium

Activity

  1. Matt Jones
    Matt Jones

    At best, you could have Rack in vendor/gems - but as discussed here:

    http://groups.google.com/group/rubyonrails-core/browse_thread/threa...

    That's going to potentially lead to problems in some environments.

    July 26th, 2009 @ 05:32 AM

  2. Michael Koziarski
    Michael Koziarski
    • Assigned user set to Matt Jones
    • State changed from new to wontfix

    August 3rd, 2009 @ 06:04 AM

  3. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • Milestone cleared.

    @koz why is this a wontfix?

    August 3rd, 2009 @ 07:40 AM

  4. Michael Koziarski
    Michael Koziarski

    Not sure if that was intentional, I did a tonne of changes before
    coming home tonight and have lost track.

    Matt's the guy for 2-3-stable's gem stuff, so if he thinks it's viable
    for 2.3 then cool, otherwise happy to bump to 3.0.

    August 3rd, 2009 @ 08:48 AM

  5. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from wontfix to open

    Reopening for 3.0. The gem stuff we're working on should make this trivial (in fact, it's core to the stuff we're working on).

    Matt, do you want to open a separate ticket for this in 2.3? Or just leave it for 3.0?

    August 3rd, 2009 @ 09:02 AM

  6. Matt Jones
    Matt Jones

    I tend to agree with Koz on the wontfix (for 2.3) - the 2.3 gem loader isn't capable of supporting this well. See this discussion on the core list for more detail.

    August 3rd, 2009 @ 10:28 AM

  7. Yehuda Katz (wycats)
    Yehuda Katz (wycats)

    @matt sounds good. We should have this fully working on edge in the next week or two -- it should be natively supported once we wire up the git-as-gem support into the bundler.

    August 3rd, 2009 @ 11:17 AM

  8. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • Tag changed from rack to bundler, gem, rack

    August 3rd, 2009 @ 11:17 AM

  9. Joe Van Dyk
    Joe Van Dyk

    I'm still in the dark as to why rack is the only library that rails 2.3 requires be installed as a gem, even if it's already included in my application.

    September 8th, 2009 @ 12:03 AM

  10. Joe Van Dyk
    Joe Van Dyk

    Would it work to rescue the exception raised by rubygems if rack isn't installed as a gem?

    Or is there a reason why rack has to be loaded as a gem? For my applications, I've been commenting out the "gem 'rack'" line and everything has been working fine.

    September 8th, 2009 @ 12:06 AM

  11. Matt Jones
    Matt Jones

    @Joe Van Dyk:

    Check the links from the rails-core list above; the issue is that the gem is loaded well before the Rails initializer stuff gets to run - if you're running from an installed gem version, it's already been activated by the time you get to the "gem 'rack'" line in action_controller.rb.

    Also note the discussion of the behavior under Passenger; in summary, it's not currently practical to vendor Rack because it won't work consistently across deployment environments. You can try unpacking it in vendor/gems, but there's no guarantee it will work correctly everywhere.

    September 8th, 2009 @ 12:26 AM

  12. Joe Van Dyk
    Joe Van Dyk

    Matt -- if the rack gem has already been loaded by the time the code gets to "gem 'rack'", then why have it there?

    September 8th, 2009 @ 12:30 AM

  13. Matt Jones
    Matt Jones

    There's a key difference for gems between 'loaded' and 'activated'. 'Loaded' is what most people think of - the gem has executed its initialization code and loaded its classes into memory; typically this is accomplished with require. 'Activated' is more complicated. A gem is 'activated' after you call "gem 'foobar'", but all that means is that its spec has been loaded and the declared load paths added to the Ruby load path. 'gem "foobar"' does one other thing: if it's passed a version string and the gem is already activated, it verifies that the activated gem satisfies the version requirement and fails if it doesn't. So the "gem 'rack', '~> 1.0.0'" line serves to both activate Rack and verify that the version is 1.0.x, avoiding weird errors down the line if it's not.

    September 8th, 2009 @ 01:21 AM

  14. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from open to invalid

    February 24th, 2010 @ 07:25 AM

  15. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Medium

    October 15th, 2010 @ 11:01 PM