Browse files

(#9296) Fix loading rack for rubygems >= 1.8

Rubygems version 1.8 broke some of the ways vendored gems used to work in Rails
2. This commit updates the config/environment.rb to add all of the gem libs to
the rails autoload_paths. It also updates the actionpack action_controller
library to not call out to gem explicitly. We know that the correct rack
version is being supplied in the vendored gems, so the following require 'rack'
line will succeed.

This also munges the load path in config/boot.rb because boot.rb doesn't load
environment.rb right away, and so can't find rack, due to the same gem problem.
So this uses the same loop as in environment.rb, but instead of the rails
autoload_paths, it adds the libs to $:, or $LOAD_PATH.
  • Loading branch information...
haus committed Oct 16, 2012
1 parent 24b801f commit a3f258849778b1a35597314b50b50d0ceae4a09b
Showing with 6 additions and 1 deletion.
  1. +3 −0 config/boot.rb
  2. +3 −0 config/environment.rb
  3. +0 −1 vendor/rails/actionpack/lib/action_controller.rb
@@ -2,6 +2,9 @@
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+Dir["#{RAILS_ROOT}/vendor/gems/**"].each do |dir|
+ $:.unshift( = "#{dir}/lib") ? lib : dir)
module Rails
class << self
@@ -24,6 +24,9 @@
# Add additional load paths for your own custom dirs
config.autoload_paths += %W( #{RAILS_ROOT}/app/mixins )
+ Dir["#{RAILS_ROOT}/vendor/gems/**"].each do |dir|
+ config.autoload_paths.unshift( = "#{dir}/lib") ? lib : dir)
+ end
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
@@ -31,7 +31,6 @@
-gem 'rack', '~> 1.1.0'
require 'rack'
require 'action_controller/cgi_ext'

0 comments on commit a3f2588

Please sign in to comment.