aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorMatt Jones <al2o3cr@gmail.com>2008-10-26 02:25:52 -0400
committerMichael Koziarski <michael@koziarski.com>2008-11-01 17:35:56 +0100
commit01433af6a5dd5bcd71a70574e7d0b356ba7b0246 (patch)
treef76c17d1d3ceef844b2a5b53221a29ca00ab18aa /railties/lib
parent62ffc6e4db1eecfe5c5a5f7471a9c39d665ada56 (diff)
downloadrails-01433af6a5dd5bcd71a70574e7d0b356ba7b0246.tar.gz
rails-01433af6a5dd5bcd71a70574e7d0b356ba7b0246.tar.bz2
rails-01433af6a5dd5bcd71a70574e7d0b356ba7b0246.zip
Make refresh_specs more resilient. Always add vendor/gems to gem search path. Use Gem.clear_paths to ensure we get a current searcher.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb1
-rw-r--r--railties/lib/rails/gem_dependency.rb37
-rw-r--r--railties/lib/tasks/gems.rake3
3 files changed, 27 insertions, 14 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 6500b2d309..e3a0e3bad1 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -267,6 +267,7 @@ module Rails
end
def add_gem_load_paths
+ Rails::GemDependency.add_frozen_gem_path
unless @configuration.gems.empty?
require "rubygems"
@configuration.gems.each { |gem| gem.add_load_paths }
diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb
index 46d5fd3a47..cd280ac023 100644
--- a/railties/lib/rails/gem_dependency.rb
+++ b/railties/lib/rails/gem_dependency.rb
@@ -18,11 +18,14 @@ module Rails
def self.add_frozen_gem_path
@@paths_loaded ||= begin
- Gem.source_index = Rails::VendorGemSourceIndex.new(Gem.source_index)
+ source_index = Rails::VendorGemSourceIndex.new(Gem.source_index)
+ Gem.clear_paths
+ Gem.source_index = source_index
# loaded before us - we can't change them, so mark them
Gem.loaded_specs.each do |name, spec|
@@framework_gems[name] = spec
end
+ true
end
end
@@ -170,19 +173,27 @@ module Rails
exact_dep = Gem::Dependency.new(name, "= #{specification.version}")
matches = real_gems.search(exact_dep)
installed_spec = matches.first
- if installed_spec
- # we have a real copy
- # get a fresh spec - matches should only have one element
- # note that there is no reliable method to check that the loaded
- # spec is the same as the copy from real_gems - Gem.activate changes
- # some of the fields
- real_spec = Gem::Specification.load(matches.first.loaded_from)
- write_spec(directory, real_spec)
- puts "Reloaded specification for #{name} from installed gems."
+ if File.exist?(File.dirname(spec_filename(directory)))
+ if installed_spec
+ # we have a real copy
+ # get a fresh spec - matches should only have one element
+ # note that there is no reliable method to check that the loaded
+ # spec is the same as the copy from real_gems - Gem.activate changes
+ # some of the fields
+ real_spec = Gem::Specification.load(matches.first.loaded_from)
+ write_spec(directory, real_spec)
+ puts "Reloaded specification for #{name} from installed gems."
+ else
+ # the gem isn't installed locally - write out our current specs
+ write_spec(directory, specification)
+ puts "Gem #{name} not loaded locally - writing out current spec."
+ end
else
- # the gem isn't installed locally - write out our current specs
- write_spec(directory, specification)
- puts "Gem #{name} not loaded locally - writing out current spec."
+ if framework_gem?
+ puts "Gem directory for #{name} not found - check if it's loading before rails."
+ else
+ puts "Something bad is going on - gem directory not found for #{name}."
+ end
end
end
diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake
index e2cb4b9577..754e3ba5c9 100644
--- a/railties/lib/tasks/gems.rake
+++ b/railties/lib/tasks/gems.rake
@@ -6,10 +6,11 @@ task :gems => 'gems:base' do
puts
puts "I = Installed"
puts "F = Frozen"
+ puts "R = Framework (loaded before rails starts)"
end
def print_gem_status(gem, indent=1)
- code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " "
+ code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " "
puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded?
end