Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1-0-stable'

Conflicts:
	lib/bundler/cli.rb
	lib/bundler/source.rb
  • Loading branch information...
commit e48440a6c15d48595485c3d1342d4fa433792ae9 2 parents 850b161 + 7c6a566
@indirect indirect authored
View
14 Rakefile
@@ -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
View
13 lib/bundler.rb
@@ -9,6 +9,7 @@
require 'yaml'
require 'bundler/rubygems_ext'
+require 'bundler/rubygems_integration'
require 'bundler/version'
module Bundler
@@ -87,7 +88,6 @@ def ui
end
def bundle_path
- # STDERR.puts settings.path
@bundle_path ||= Pathname.new(settings.path).expand_path(root)
end
@@ -140,11 +140,11 @@ def definition(unlock = nil)
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
@@ -261,8 +261,9 @@ def configure_gem_home_and_path
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
@@ -270,7 +271,7 @@ def configure_gem_home_and_path
# 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
View
8 lib/bundler/cli.rb
@@ -4,9 +4,6 @@
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 @@ def initialize(*)
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")
@@ -162,6 +159,7 @@ def install
end
opts[:without].map!{|g| g.to_sym }
+ # Can't use Bundler.settings for this because settings needs gemfile.dirname
ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
@@ -219,7 +217,7 @@ def install
"Use `bundle show [gemname]` to see where a bundled gem is installed."
end
rescue GemNotFound => e
- if opts[:local]
+ if opts[:local] && Bundler.app_cache.exist?
Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
end
View
2  lib/bundler/definition.rb
@@ -61,7 +61,7 @@ def initialize(lockfile, dependencies, sources, unlock)
@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]
View
17 lib/bundler/installer.rb
@@ -10,6 +10,14 @@ def self.install(root, definition, options = {})
end
def run(options)
+ # Create the BUNDLE_PATH directory
+ begin
+ Bundler.bundle_path.mkpath unless Bundler.bundle_path.exist?
+ rescue Errno::EEXIST
+ raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " +
+ "because of an invalid symlink. Remove the symlink so the directory can be created."
+ end
+
if Bundler.settings[:frozen]
@definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
end
@@ -35,9 +43,6 @@ def run(options)
@definition.resolve_remotely!
end
- # Ensure that BUNDLE_PATH exists
- Bundler.mkdir_p(Bundler.bundle_path) unless File.exist?(Bundler.bundle_path)
-
# Must install gems in the order that the resolver provides
# as dependencies might actually affect the installation of
# the gem.
@@ -49,13 +54,9 @@ def run(options)
# 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 ""
View
301 lib/bundler/rubygems_integration.rb
@@ -0,0 +1,301 @@
+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
+
+ # 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)
+ Gem::Specification.all = specs
+
+ Gem.post_reset {
+ Gem::Specification.all = specs
+ }
+
+ stub_source_index170(specs)
+ end
+
+ def all_specs
+ Gem::Specification.to_a
+ 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? :all=
+ @rubygems = RubygemsIntegration::Modern.new
+ else
+ @rubygems = RubygemsIntegration::Transitional.new
+ end
+ else
+ @rubygems = RubygemsIntegration::Legacy.new
+ end
+
+ class << self
+ attr_reader :rubygems
+ end
+end
View
10 lib/bundler/runtime.rb
@@ -11,7 +11,7 @@ def setup(*groups)
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 @@ def setup(*groups)
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 @@ def setup(*groups)
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 @@ def prune_cache
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)
@@ -176,7 +176,7 @@ def cache_path
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
View
4 lib/bundler/settings.rb
@@ -79,7 +79,7 @@ def path
if path = self[:path]
"#{path}/#{Bundler.ruby_scope}"
else
- Gem.dir
+ Bundler.rubygems.gem_dir
end
end
@@ -106,7 +106,7 @@ def set_key(key, value, hash, file)
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
View
113 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,118 +62,12 @@ def clean_load_path
$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
-
- # === Following hacks are to improve on the generated bin wrappers ===
-
- # 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
-
- # OMG more hacks
- gem_class = (class << Gem ; self ; end)
- gem_class.send(:remove_method, :refresh)
- gem_class.send(:define_method, :refresh) { }
- 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
-
- Gem.clear_paths
- end
-
extend self
end
end
View
44 lib/bundler/source.rb
@@ -19,7 +19,9 @@ def initialize(options = {})
@allow_remote = false
@allow_cached = false
- @caches = [ Bundler.app_cache ] + Gem.path.map{ |p| File.expand_path("#{p}/cache") }
+ @caches = [ Bundler.app_cache ]
+ @caches << Bundler.rubygems.gem_path.map{|p| File.expand_path("#{p}/cache") }
@al2o3cr
al2o3cr added a note

Bundler::RubygemsIntegration defines gem_path as Gem.path.to_s so this blows up - something's not right...

@evanphx Collaborator
evanphx added a note

"blows up" being what? The tests pass fine.

@evanphx Collaborator
evanphx added a note

Ok, I see what you mean. I wonder why the tests pass....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
@spec_fetch_map = {}
end
@@ -71,7 +73,7 @@ def fetch(spec)
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
@@ -86,7 +88,7 @@ def install(spec)
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,
@@ -98,16 +100,16 @@ def install(spec)
# 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)
@@ -160,7 +162,7 @@ def installed_specs
@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
@@ -194,7 +196,7 @@ def cached_specs
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
@@ -210,7 +212,7 @@ def cached_specs
def remote_specs(dependencies = nil)
@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}"
@@ -232,21 +234,21 @@ def remote_specs(dependencies = nil)
end
idx
ensure
- Gem.sources = old
+ Bundler.rubygems.sources = old
end
end
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
@@ -361,8 +363,8 @@ def local_specs(*)
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
@@ -376,9 +378,9 @@ def generate_bin
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
View
18 spec/install/invalid_spec.rb
@@ -15,3 +15,21 @@
end
end
+
+describe "bundle install to a dead symlink" do
+ before do
+ in_app_root do
+ `ln -s /tmp/idontexist bundle`
+ end
+ end
+
+ it "reports the symlink is dead" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle "install --path bundle"
+ out.should =~ /invalid symlink/
+ end
+end
View
2  spec/lock/git_spec.rb
@@ -27,7 +27,7 @@
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
View
3  spec/other/exec_spec.rb
@@ -83,7 +83,8 @@
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)
View
4 spec/runtime/setup_spec.rb
@@ -166,7 +166,7 @@
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 @@
run <<-R
Gem.refresh
- puts Gem.source_index.find_name("rack").inspect
+ puts Bundler.rubygems.find_name("rack").inspect
R
out.should == "[]"
Please sign in to comment.
Something went wrong with that request. Please try again.