diff options
-rw-r--r-- | Rakefile | 14 | ||||
-rw-r--r-- | lib/bundler.rb | 12 | ||||
-rw-r--r-- | lib/bundler/cli.rb | 5 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 2 | ||||
-rw-r--r-- | lib/bundler/installer.rb | 6 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 304 | ||||
-rw-r--r-- | lib/bundler/runtime.rb | 10 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 4 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 134 | ||||
-rw-r--r-- | lib/bundler/source.rb | 46 | ||||
-rw-r--r-- | spec/lock/git_spec.rb | 2 | ||||
-rw-r--r-- | spec/other/exec_spec.rb | 3 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 4 |
13 files changed, 370 insertions, 176 deletions
@@ -76,12 +76,26 @@ begin system("git checkout #{rg}") system("git pull origin master") if rg == "master" end + puts "Running bundler specs against rubygems '#{rg}'" ENV["RUBYOPT"] = "-I#{File.expand_path("tmp/rubygems/lib")} #{rubyopt}" end task rg => "clone_rubygems_#{rg}" task "rubygems:all" => rg end + + desc "Run specs under a Rubygems checkout (set RG=path)" + RSpec::Core::RakeTask.new("co") do |t| + t.rspec_opts = %w(-fs --color) + t.ruby_opts = %w(-w) + end + + task "setup_co" do + ENV["RUBYOPT"] = "-I#{File.expand_path ENV['RG']} #{rubyopt}" + end + + task "co" => "setup_co" + task "rubygems:all" => "co" end namespace :ruby do diff --git a/lib/bundler.rb b/lib/bundler.rb index 40f38928..b70f718a 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -9,6 +9,7 @@ end require 'yaml' require 'bundler/rubygems_ext' +require 'bundler/rubygems_integration' require 'bundler/version' module Bundler @@ -137,11 +138,11 @@ module Bundler end def ruby_scope - "#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}" + "#{Bundler.rubygems.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}" end def user_bundle_path - Pathname.new(Gem.user_home).join(".bundler") + Pathname.new(Bundler.rubygems.user_home).join(".bundler") end def home @@ -258,8 +259,9 @@ module Bundler if settings[:disable_shared_gems] ENV['GEM_PATH'] = '' ENV['GEM_HOME'] = File.expand_path(bundle_path, root) - elsif Gem.dir != bundle_path.to_s - paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? } + elsif Bundler.rubygems.gem_dir != bundle_path.to_s + possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path] + paths = possibles.flatten.compact.uniq.reject { |p| p.empty? } ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR) ENV["GEM_HOME"] = bundle_path.to_s end @@ -267,7 +269,7 @@ module Bundler # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602) FileUtils.mkdir_p bundle_path.to_s rescue nil - Gem.clear_paths + Bundler.rubygems.clear_paths end def upgrade_lockfile diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index e6e43322..37f78277 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -4,9 +4,6 @@ require 'thor/actions' require 'rubygems/user_interaction' require 'rubygems/config_file' -# Work around a RubyGems bug -Gem.configuration - module Bundler class CLI < Thor include Thor::Actions @@ -16,7 +13,7 @@ module Bundler the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell) Bundler.ui = UI::Shell.new(the_shell) Bundler.ui.debug! if options["verbose"] - Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui) + Bundler.rubygems.ui = UI::RGProxy.new(Bundler.ui) end check_unknown_options! unless ARGV.include?("exec") || ARGV.include?("config") diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 854e3f53..962838aa 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -61,7 +61,7 @@ module Bundler @unlock[:gems] ||= [] @unlock[:sources] ||= [] - current_platform = Gem.platforms.map { |p| generic(p) }.compact.last + current_platform = Bundler.rubygems.platforms.map { |p| generic(p) }.compact.last @new_platform = !@platforms.include?(current_platform) @platforms |= [current_platform] diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 524f6b43..e0728a25 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -54,13 +54,9 @@ module Bundler # next # end - begin - old_args = Gem::Command.build_args - Gem::Command.build_args = [Bundler.settings["build.#{spec.name}"]] + Bundler.rubygems.with_build_args [Bundler.settings["build.#{spec.name}"]] do spec.source.install(spec) Bundler.ui.debug "from #{spec.loaded_from} " - ensure - Gem::Command.build_args = old_args end Bundler.ui.info "" diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb new file mode 100644 index 00000000..ef6446f6 --- /dev/null +++ b/lib/bundler/rubygems_integration.rb @@ -0,0 +1,304 @@ +module Bundler + class RubygemsIntegration + def initialize + # Work around a RubyGems bug + configuration + end + + def is_19? + false + end + + # Make sure that rubygems has fully loaded (1.9 partially loads + # sometimes) + def fully_load! + Gem.source_index if is_19? + end + + def loaded_specs(name) + Gem.loaded_specs[name] + end + + def mark_loaded(spec) + Gem.loaded_specs[spec.name] = spec + end + + def path(obj) + Gem::Path.path(obj) + end + + def platforms + Gem.platforms + end + + def configuration + Gem.configuration + end + + def ruby_engine + Gem.ruby_engine + end + + def read_binary(path) + Gem.read_binary(path) + end + + def inflate(obj) + Gem.inflate(obj) + end + + def sources=(val) + Gem.sources = val + end + + def sources + Gem.sources + end + + def gem_dir + Gem.dir.to_s + end + + def gem_bindir + Gem.bindir + end + + def user_home + Gem.user_home + end + + def gem_path + Gem.path.to_s + end + + def marshal_spec_dir + Gem::MARSHAL_SPEC_DIR + end + + def clear_paths + Gem.clear_paths + end + + def bin_path(gem, bin, ver) + Gem.bin_path(gem, bin, ver) + end + + def ui=(obj) + Gem::DefaultUserInteraction.ui = obj + end + + def fetch_specs(all, pre, &blk) + Gem::SpecFetcher.new.list(all, pre).each(&blk) + end + + def with_build_args(args) + old_args = Gem::Command.build_args + begin + Gem::Command.build_args = args + yield + ensure + Gem::Command.build_args = old_args + end + end + + def spec_from_gem(path) + Gem::Format.from_file_by_path(path).spec + end + + def download_gem(spec, uri, path) + Gem::RemoteFetcher.fetcher.download(spec, uri, path) + end + + def reverse_rubygems_kernel_mixin + # Disable rubygems' gem activation system + ::Kernel.class_eval do + if private_method_defined?(:gem_original_require) + alias rubygems_require require + alias require gem_original_require + end + + undef gem + end + end + + def replace_gem(specs) + executables = specs.map { |s| s.executables }.flatten + + ::Kernel.send(:define_method, :gem) do |dep, *reqs| + if executables.include? File.basename(caller.first.split(':').first) + return + end + opts = reqs.last.is_a?(Hash) ? reqs.pop : {} + + unless dep.respond_to?(:name) && dep.respond_to?(:requirement) + dep = Gem::Dependency.new(dep, reqs) + end + + spec = specs.find { |s| s.name == dep.name } + + if spec.nil? + + e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile." + e.name = dep.name + if e.respond_to?(:requirement=) + e.requirement = dep.requirement + else + e.version_requirement = dep.requirement + end + raise e + elsif dep !~ spec + e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \ + "Make sure all dependencies are added to Gemfile." + e.name = dep.name + if e.respond_to?(:requirement=) + e.requirement = dep.requirement + else + e.version_requirement = dep.requirement + end + raise e + end + + true + end + end + + def stub_source_index137(specs) + # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in + source_index_class = (class << Gem::SourceIndex ; self ; end) + source_index_class.send(:remove_method, :from_gems_in) + source_index_class.send(:define_method, :from_gems_in) do |*args| + source_index = Gem::SourceIndex.new + source_index.spec_dirs = *args + source_index.add_specs(*specs) + source_index + end + end + + def stub_source_index170(specs) + Gem::SourceIndex.send(:define_method, :initialize) do |*args| + @gems = {} + self.spec_dirs = *args + add_specs(*specs) + end + end + + # Replace the method that finds all specs on the system + # and replace it with one that just returns out static view. + def stub_load_all_spec(specs) + sc = (class << Gem::Specification; self; end) + sc.send(:remove_method, :load_all_specs) + sc.send(:define_method, :load_all_specs) { specs } + end + + # Used to make bin stubs that are not created by bundler work + # under bundler. The new Gem.bin_path only considers gems in + # +specs+ + def replace_bin_path(specs) + gem_class = (class << Gem ; self ; end) + gem_class.send(:remove_method, :bin_path) + gem_class.send(:define_method, :bin_path) do |name, *args| + exec_name, *reqs = args + + if exec_name == 'bundle' + return ENV['BUNDLE_BIN_PATH'] + end + + spec = nil + + if exec_name + spec = specs.find { |s| s.executables.include?(exec_name) } + spec or raise Gem::Exception, "can't find executable #{exec_name}" + else + spec = specs.find { |s| s.name == name } + exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" + end + + gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) + gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) + File.exist?(gem_bin) ? gem_bin : gem_from_path_bin + end + end + + # Because Bundler has a static view of what specs are available, + # we don't #reflesh, so stub it out. + def replace_refresh + gem_class = (class << Gem ; self ; end) + gem_class.send(:remove_method, :refresh) + gem_class.send(:define_method, :refresh) { } + end + + # Replace or hook into Rubygems to provide a bundlerized view + # of the world. + def replace_entrypoints(specs) + reverse_rubygems_kernel_mixin + + replace_gem(specs) + + stub_rubygems(specs) + + replace_bin_path(specs) + replace_refresh + + Gem.clear_paths + end + + class Modern < RubygemsIntegration + def stub_rubygems(specs) + stub_load_all_spec(specs) + stub_source_index170(specs) + end + + def all_specs + Gem::Specification.all + end + + def find_name(name) + Gem::Specification.find_all_by_name name + end + + end + + class Legacy < RubygemsIntegration + def stub_rubygems(specs) + stub_source_index137(specs) + end + + def path(obj) + obj.to_s + end + + def all_specs + Gem.source_index.all_gems.values + end + + def find_name(name) + Gem.source_index.find_name(name) + end + end + + class Transitional < Legacy + def stub_rubygems(specs) + stub_source_index170(specs) + end + + def path(obj) + obj.to_s + end + end + + end + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0') + if Gem::Specification.respond_to? :load_all_specs + @rubygems = RubygemsIntegration::Modern.new + else + @rubygems = RubygemsIntegration::Transitional.new + end + else + @rubygems = RubygemsIntegration::Legacy.new + end + + class << self + attr_reader :rubygems + end +end diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index f8109b03..426c9ba9 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -11,7 +11,7 @@ module Bundler specs = groups.any? ? @definition.specs_for(groups) : requested_specs setup_environment - cripple_rubygems(specs) + Bundler.rubygems.replace_entrypoints(specs) # Activate the specs specs.each do |spec| @@ -19,7 +19,7 @@ module Bundler raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it." end - if activated_spec = Gem.loaded_specs[spec.name] and activated_spec.version != spec.version + if activated_spec = Bundler.rubygems.loaded_specs(spec.name) and activated_spec.version != spec.version e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \ "but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec." e.name = spec.name @@ -31,7 +31,7 @@ module Bundler raise e end - Gem.loaded_specs[spec.name] = spec + Bundler.rubygems.mark_loaded(spec) load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)} $LOAD_PATH.unshift(*load_paths) end @@ -102,7 +102,7 @@ module Bundler cached = Dir["#{cache_path}/*.gem"] cached = cached.delete_if do |path| - spec = Gem::Format.from_file_by_path(path).spec + spec = Bundler.rubygems.spec_from_gem path resolve.any? do |s| s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git) @@ -127,7 +127,7 @@ module Bundler def setup_environment begin - ENV["BUNDLE_BIN_PATH"] = Gem.bin_path("bundler", "bundle", VERSION) + ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) rescue Gem::GemNotFoundException ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__) end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 854f3b4a..c3209c3a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -79,7 +79,7 @@ module Bundler if path = self[:path] "#{path}/#{Bundler.ruby_scope}" else - Gem.dir + Bundler.rubygems.gem_dir end end @@ -106,7 +106,7 @@ module Bundler end def global_config_file - file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config") + file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config") Pathname.new(file) end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 2f442d0f..66aa3a2b 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -1,6 +1,9 @@ require 'pathname' require 'rubygems' -Gem.source_index # ensure Rubygems is fully loaded in Ruby 1.9 + +require 'bundler/rubygems_integration' + +Bundler.rubygems.fully_load! module Gem class Dependency @@ -59,139 +62,12 @@ module Bundler $LOAD_PATH.reject! do |p| next if File.expand_path(p) =~ /^#{me}/ p != File.dirname(__FILE__) && - Gem.path.any?{|gp| p =~ /^#{gp}/ } + Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{gp}/ } end $LOAD_PATH.uniq! end end - def reverse_rubygems_kernel_mixin - # Disable rubygems' gem activation system - ::Kernel.class_eval do - if private_method_defined?(:gem_original_require) - alias rubygems_require require - alias require gem_original_require - end - - undef gem - end - end - - def cripple_rubygems(specs) - reverse_rubygems_kernel_mixin - - executables = specs.map { |s| s.executables }.flatten - Gem.source_index # ensure RubyGems is fully loaded - - ::Kernel.send(:define_method, :gem) do |dep, *reqs| - if executables.include? File.basename(caller.first.split(':').first) - return - end - opts = reqs.last.is_a?(Hash) ? reqs.pop : {} - - unless dep.respond_to?(:name) && dep.respond_to?(:requirement) - dep = Gem::Dependency.new(dep, reqs) - end - - spec = specs.find { |s| s.name == dep.name } - - if spec.nil? - - e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile." - e.name = dep.name - if e.respond_to?(:requirement=) - e.requirement = dep.requirement - else - e.version_requirement = dep.requirement - end - raise e - elsif dep !~ spec - e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \ - "Make sure all dependencies are added to Gemfile." - e.name = dep.name - if e.respond_to?(:requirement=) - e.requirement = dep.requirement - else - e.version_requirement = dep.requirement - end - raise e - end - - true - end - - bundlerize_source_index(specs) - bundlerize_bin_path(specs) - bundlerize_refresh - - Gem.clear_paths - end - - # Redefining the source index ensures that all gems that Bundler has set up (including git gems) - # will be available with working methods like #full_gem_path. - def bundlerize_source_index(specs) - return unless defined?(Gem::SourceIndex) - - # Yeah, talk about a hack - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0') - Gem::SourceIndex.send(:define_method, :initialize) do |*args| - @gems = {} - self.spec_dirs = *args - add_specs(*specs) - end - else - # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in - source_index_class = (class << Gem::SourceIndex ; self ; end) - source_index_class.send(:remove_method, :from_gems_in) - source_index_class.send(:define_method, :from_gems_in) do |*args| - source_index = Gem::SourceIndex.new - source_index.spec_dirs = *args - source_index.add_specs(*specs) - source_index - end - end - end - - # Redefining Gem.bin_path means that the binstubs generated by rubygems (eg, /usr/bin/rake) - # will be redirected to load the correct bin, even if that bin is in a git checkout. - def bundlerize_bin_path(specs) - return unless Gem.respond_to?(:bin_path) - - gem_class = (class << Gem ; self ; end) - gem_class.send(:remove_method, :bin_path) - gem_class.send(:define_method, :bin_path) do |name, *args| - exec_name, *reqs = args - - if exec_name == 'bundle' - return ENV['BUNDLE_BIN_PATH'] - end - - spec = nil - - if exec_name - spec = specs.find { |s| s.executables.include?(exec_name) } - spec or raise Gem::Exception, "can't find executable #{exec_name}" - else - spec = specs.find { |s| s.name == name } - exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}" - end - - gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name) - gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name) - File.exist?(gem_bin) ? gem_bin : gem_from_path_bin - end - end - - # Bundler can't reload itself or any of the gems that have already been loaded, so it seems like - # there isn't much we can do except flat out lie about refreshing things. - def bundlerize_refresh - return unless Gem.respond_to?(:refresh) - - gem_class = (class << Gem ; self ; end) - gem_class.send(:remove_method, :refresh) - gem_class.send(:define_method, :refresh) { } - end - extend self end end diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index e2c13f5d..86f168d5 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -17,8 +17,12 @@ module Bundler @remotes = (options["remotes"] || []).map { |r| normalize_uri(r) } @allow_remote = false @allow_cached = false + # Hardcode the paths for now - @caches = [ Bundler.app_cache ] + Gem.path.map { |p| File.expand_path("#{p}/cache") } + @caches = [ Bundler.app_cache ] + Bundler.rubygems.gem_path.map do |x| + File.expand_path("#{x}/cache") + end + @spec_fetch_map = {} end @@ -70,7 +74,7 @@ module Bundler spec, uri = @spec_fetch_map[spec.full_name] if spec path = download_gem_from_uri(spec, uri) - s = Gem::Format.from_file_by_path(path).spec + s = Bundler.rubygems.spec_from_gem(path) spec.__swap__(s) end end @@ -85,7 +89,7 @@ module Bundler Bundler.ui.info "Installing #{spec.name} (#{spec.version}) " - install_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir + install_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir options = { :install_dir => install_path, :ignore_dependencies => true, :wrappers => true, @@ -97,16 +101,16 @@ module Bundler # SUDO HAX if Bundler.requires_sudo? - sudo "mkdir -p #{Gem.dir}/gems #{Gem.dir}/specifications" - sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Gem.dir}/gems/" - sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Gem.dir}/specifications/" + sudo "mkdir -p #{Bundler.rubygems.gem_dir}/gems #{Bundler.rubygems.gem_dir}/specifications" + sudo "cp -R #{Bundler.tmp}/gems/#{spec.full_name} #{Bundler.rubygems.gem_dir}/gems/" + sudo "cp -R #{Bundler.tmp}/specifications/#{spec.full_name}.gemspec #{Bundler.rubygems.gem_dir}/specifications/" spec.executables.each do |exe| - sudo "mkdir -p #{Gem.bindir}" - sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.bindir}" + sudo "mkdir -p #{Bundler.rubygems.bindir}" + sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_bindir}" end end - spec.loaded_from = "#{Gem.dir}/specifications/#{spec.full_name}.gemspec" + spec.loaded_from = "#{Bundler.rubygems.gem_dir}/specifications/#{spec.full_name}.gemspec" end def sudo(str) @@ -159,7 +163,7 @@ module Bundler @installed_specs ||= begin idx = Index.new have_bundler = false - Gem.source_index.to_a.reverse.each do |dont_use_this_var, spec| + Bundler.rubygems.all_specs.reverse.each do |spec| next if spec.name == 'bundler' && spec.version.to_s != VERSION have_bundler = true if spec.name == 'bundler' spec.source = self @@ -193,7 +197,7 @@ module Bundler next if gemfile =~ /bundler\-[\d\.]+?\.gem/ begin - s ||= Gem::Format.from_file_by_path(gemfile).spec + s ||= Bundler.rubygems.spec_from_gem(gemfile) rescue Gem::Package::FormatError raise GemspecError, "Could not read gem at #{gemfile}. It may be corrupted." end @@ -209,7 +213,7 @@ module Bundler def remote_specs @remote_specs ||= begin idx = Index.new - old = Gem.sources + old = Bundler.rubygems.sources remotes.each do |uri| Bundler.ui.info "Fetching source index for #{uri}" @@ -226,7 +230,7 @@ module Bundler end idx ensure - Gem.sources = old + Bundler.rubygems.sources = old end end @@ -248,14 +252,14 @@ module Bundler def download_gem_from_uri(spec, uri) spec.fetch_platform - download_path = Bundler.requires_sudo? ? Bundler.tmp : Gem.dir - gem_path = "#{Gem.dir}/cache/#{spec.full_name}.gem" + download_path = Bundler.requires_sudo? ? Bundler.tmp : Bundler.rubygems.gem_dir + gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem" FileUtils.mkdir_p("#{download_path}/cache") - Gem::RemoteFetcher.fetcher.download(spec, uri, download_path) + Bundler.rubygems.download_gem(spec, uri, download_path) if Bundler.requires_sudo? - sudo "mkdir -p #{Gem.dir}/cache" + sudo "mkdir -p #{Bundler.rubygems.gem_dir}/cache" sudo "mv #{Bundler.tmp}/cache/#{spec.full_name}.gem #{gem_path}" end @@ -370,8 +374,8 @@ module Bundler class Installer < Gem::Installer def initialize(spec, options = {}) @spec = spec - @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Gem.dir}/bin" - @gem_dir = spec.full_gem_path + @bin_dir = Bundler.requires_sudo? ? "#{Bundler.tmp}/bin" : "#{Bundler.rubygems.gem_dir}/bin" + @gem_dir = Bundler.rubygems.path(spec.full_gem_path) @wrappers = options[:wrappers] || true @env_shebang = options[:env_shebang] || true @format_executable = options[:format_executable] || false @@ -385,9 +389,9 @@ module Bundler end super if Bundler.requires_sudo? - Bundler.mkdir_p "#{Gem.dir}/bin" + Bundler.mkdir_p "#{Bundler.rubygems.gem_dir}/bin" spec.executables.each do |exe| - Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Gem.dir}/bin/" + Bundler.sudo "cp -R #{Bundler.tmp}/bin/#{exe} #{Bundler.rubygems.gem_dir}/bin/" end end end diff --git a/spec/lock/git_spec.rb b/spec/lock/git_spec.rb index da392115..7d023b83 100644 --- a/spec/lock/git_spec.rb +++ b/spec/lock/git_spec.rb @@ -27,7 +27,7 @@ describe "bundle lock with git gems" do it "provides correct #full_gem_path" do run <<-RUBY - puts Gem.source_index.find_name('foo').first.full_gem_path + puts Bundler.rubygems.find_name('foo').first.full_gem_path RUBY out.should == bundle("show foo") end diff --git a/spec/other/exec_spec.rb b/spec/other/exec_spec.rb index 9cb70464..6bafd5e6 100644 --- a/spec/other/exec_spec.rb +++ b/spec/other/exec_spec.rb @@ -83,7 +83,8 @@ describe "bundle exec" do gem "rack" G - rubyopt = "-I#{bundler_path} -rbundler/setup" + rubyopt = ENV['RUBYOPT'] + rubyopt = "-I#{bundler_path} -rbundler/setup #{rubyopt}" bundle "exec 'echo $RUBYOPT'" out.should have_rubyopts(rubyopt) diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index fe755238..c122ccc2 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -166,7 +166,7 @@ describe "Bundler.setup" do should_be_installed "rack 1.0.0" end - describe "crippling rubygems" do + describe "integrate with rubygems" do describe "by replacing #gem" do before :each do install_gemfile <<-G @@ -522,7 +522,7 @@ describe "Bundler.setup" do run <<-R Gem.refresh - puts Gem.source_index.find_name("rack").inspect + puts Bundler.rubygems.find_name("rack").inspect R out.should == "[]" |