<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -58,7 +58,7 @@ module GemManagement
       installer = Gem::DependencyInstaller.new(options.merge(:user_install =&gt; false))
       
       # Force-refresh certain gems by excluding them from the current index
-      if refresh.respond_to?(:include?) &amp;&amp; !refresh.empty?
+      if !options[:ignore_dependencies] &amp;&amp; refresh.respond_to?(:include?) &amp;&amp; !refresh.empty?
         source_index = installer.instance_variable_get(:@source_index)
         source_index.gems.each do |name, spec| 
           source_index.gems.delete(name) if refresh.include?(spec.name)
@@ -81,7 +81,7 @@ module GemManagement
         exception = e
       end
       if installer.installed_gems.empty? &amp;&amp; exception
-        error &quot;Failed to install gem '#{gem} (#{version})' (#{exception.message})&quot;
+        error &quot;Failed to install gem '#{gem} (#{version || 'any version'})' (#{exception.message})&quot;
       end
       installer.installed_gems.each do |spec|
         success &quot;Successfully installed #{spec.full_name}&quot;
@@ -122,11 +122,13 @@ module GemManagement
   # install_gem_from_source(source_dir, gem_name)
   # install_gem_from_source(source_dir, :skip =&gt; [...])
   def install_gem_from_source(source_dir, *args)
+    installed_gems = []
     Dir.chdir(source_dir) do
-      options = args.last.is_a?(Hash) ? args.pop : {}
-      gem_name    = args[0] || File.basename(source_dir)
-      gem_pkg_dir = File.join(source_dir, 'pkg')
-      skip_gems   = options.delete(:skip) || []
+      opts = args.last.is_a?(Hash) ? args.pop : {}
+      gem_name     = args[0] || File.basename(source_dir)
+      gem_pkg_dir  = File.join(source_dir, 'pkg')
+      gem_pkg_glob = File.join(gem_pkg_dir, &quot;#{gem_name}-*.gem&quot;)
+      skip_gems    = opts.delete(:skip) || []
 
       # Cleanup what's already there
       clobber(source_dir)
@@ -138,7 +140,7 @@ module GemManagement
       
       if packages.length == 1
         # The are no subpackages for the main package
-        options[:refresh] = [gem_name]
+        refresh = [gem_name]
       else
         # Gather all packages into the top-level pkg directory
         packages.each do |pkg|
@@ -149,24 +151,38 @@ module GemManagement
         package(source_dir, false)
         
         # Gather subgems to refresh during installation of the main gem
-        options[:refresh] = packages.map do |pkg|
+        refresh = packages.map do |pkg|
           File.basename(pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1] rescue nil
         end.compact
-      end
-    
-      gem_pkg = Dir[File.join(gem_pkg_dir, &quot;#{gem_name}-*.gem&quot;)][0]
-      if gem_pkg &amp;&amp; File.exists?(gem_pkg)
-        # Needs to be executed from the directory that contains all packages
-        Dir.chdir(File.dirname(gem_pkg)) do 
-          install_gem(gem_pkg, options)
+        
+        # Install subgems explicitly even if ignore_dependencies is set
+        if opts[:ignore_dependencies]
+          refresh.each do |name| 
+            gem_pkg = Dir[File.join(gem_pkg_dir, &quot;#{name}-*.gem&quot;)][0]
+            install_pkg(gem_pkg, opts)
+          end
         end
-        options[:refresh]
+      end
+      
+      # Finally install the main gem
+      if install_pkg(Dir[gem_pkg_glob][0], opts.merge(:refresh =&gt; refresh))
+        installed_gems = refresh
       else
-        []
+        installed_gems = []
       end
     end
+    installed_gems
   end
-
+  
+  def install_pkg(gem_pkg, opts = {})
+    if (gem_pkg &amp;&amp; File.exists?(gem_pkg))
+      # Needs to be executed from the directory that contains all packages
+      Dir.chdir(File.dirname(gem_pkg)) { install_gem(gem_pkg, opts) }
+    else
+      false
+    end
+  end
+  
   # Uninstall a gem.
   def uninstall_gem(gem, options = {})
     if options[:version] &amp;&amp; !options[:version].is_a?(Gem::Requirement)
@@ -178,17 +194,17 @@ module GemManagement
 
   def clobber(source_dir)
     Dir.chdir(source_dir) do 
-      system &quot;#{Gem.ruby} -S rake -s clobber&quot; if File.exists?('Rakefile')
+      system &quot;#{Gem.ruby} -S rake -s clobber&quot; unless File.exists?('Thorfile')
     end
   end
 
   def package(source_dir, clobber = true)
     Dir.chdir(source_dir) do 
-      if File.exists?('Rakefile')
+      if File.exists?('Thorfile')
+        thor &quot;:package&quot;
+      elsif File.exists?('Rakefile')
         rake &quot;clobber&quot; if clobber
         rake &quot;package&quot;
-      elsif
-        thor &quot;:package&quot;
       end
     end
     Dir[File.join(source_dir, 'pkg/*.gem')]
@@ -230,12 +246,12 @@ module GemManagement
       ::Gem.clear_paths; ::Gem.path.unshift(gem_dir)
       ::Gem.source_index.refresh!
       dependencies.each do |dep|
-        if gemspec = ::Gem.source_index.search(dep).last
-          if gemspec.loaded_from.index(gem_dir) == 0
-            local_specs  &lt;&lt; gemspec
-          else
-            system_specs &lt;&lt; gemspec
-          end
+        gemspecs = ::Gem.source_index.search(dep)
+        local = gemspecs.reverse.find { |s| s.loaded_from.index(gem_dir) == 0 }
+        if local
+          local_specs  &lt;&lt; local
+        elsif gemspecs.last
+          system_specs &lt;&lt; gemspecs.last
         else
           missing_deps &lt;&lt; dep
         end
@@ -313,4 +329,4 @@ TEXT
     Gem.source_index.load_gems_in(File.join(dir, 'specifications'))
   end
   
-end
+end
\ No newline at end of file</diff>
      <filename>lib/merb-core/tasks/gem_management.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a7fb18c7f3cf24321ccd8a8e03f6ddafcb6be651</id>
    </parent>
  </parents>
  <author>
    <name>Fabien Franzen</name>
    <email>info@atelierfabien.be</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/dad0d934c0294e082d7dc525e61ed547daf4bf64</url>
  <id>dad0d934c0294e082d7dc525e61ed547daf4bf64</id>
  <committed-date>2008-10-11T06:37:28-07:00</committed-date>
  <authored-date>2008-10-11T06:37:28-07:00</authored-date>
  <message>Updated GemManagement</message>
  <tree>2e9e0af214840be9b94251d3bf327e8640b3de39</tree>
  <committer>
    <name>Fabien Franzen</name>
    <email>info@atelierfabien.be</email>
  </committer>
</commit>
