aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/resolver.rb19
-rw-r--r--lib/bundler/rubygems_ext.rb2
-rw-r--r--lib/bundler/rubygems_integration.rb17
-rw-r--r--lib/bundler/source/git.rb4
-rw-r--r--lib/bundler/source/path.rb15
6 files changed, 47 insertions, 12 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index a3ccd700..015892ea 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -273,6 +273,8 @@ module Bundler
method_option "path", :type => :string, :banner =>
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
+ method_option "frozen", :type => :boolean, :banner =>
+ "Do not allow the Gemfile.lock to be updated after this package operation's install"
long_desc <<-D
The package command will copy the .gem files for every gem in the bundle into the
directory ./vendor/cache. If you then check that directory into your source
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index d22ab34e..48f0d468 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -341,10 +341,11 @@ module Bundler
"try passing them all to `bundle update`"
elsif requirement.source
name = requirement.name
- versions = @source_requirements[name][name].map(&:version)
- message = String.new("Could not find gem '#{requirement}' in #{requirement.source}.\n")
- message << if versions.any?
- "Source contains '#{name}' at: #{versions.join(", ")}"
+ specs = @source_requirements[name][name]
+ versions_with_platforms = specs.map {|s| [s.version, s.platform] }
+ message = String.new("Could not find gem '#{requirement}' in #{requirement.source}.\n")
+ message << if versions_with_platforms.any?
+ "Source contains '#{name}' at: #{formatted_versions_with_platforms(versions_with_platforms)}"
else
"Source does not contain any versions of '#{requirement}'"
end
@@ -355,5 +356,15 @@ module Bundler
raise GemNotFound, message
end
end
+
+ def formatted_versions_with_platforms(versions_with_platforms)
+ version_platform_strs = versions_with_platforms.map do |vwp|
+ version = vwp.first
+ platform = vwp.last
+ version_platform_str = String.new(version.to_s)
+ version_platform_str << " #{platform}" unless platform.nil?
+ end
+ version_platform_strs.join(", ")
+ end
end
end
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 22c22a2d..2f36c29c 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -53,7 +53,7 @@ module Gem
if method_defined?(:extension_dir)
alias_method :rg_extension_dir, :extension_dir
def extension_dir
- @extension_dir ||= if source.respond_to?(:extension_dir_name)
+ @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
File.expand_path(File.join(extensions_dir, source.extension_dir_name))
else
rg_extension_dir
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 0f567db1..4e5ca7d1 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -54,10 +54,23 @@ module Bundler
def validate(spec)
Bundler.ui.silence { spec.validate(false) }
+ rescue Gem::InvalidSpecificationException => e
+ error_message = "The gemspec at #{spec.loaded_from} is not valid. Please fix this gemspec.\n" \
+ "The validation error was '#{e.message}'\n"
+ raise Gem::InvalidSpecificationException.new(error_message)
rescue Errno::ENOENT
nil
end
+ def set_installed_by_version(spec, installed_by_version = Gem::VERSION)
+ return unless spec.respond_to?(:installed_by_version=)
+ spec.installed_by_version = Gem::Version.create(installed_by_version)
+ end
+
+ def spec_missing_extensions?(spec)
+ !spec.respond_to?(:missing_extensions?) || spec.missing_extensions?
+ end
+
def path(obj)
obj.to_s
end
@@ -503,9 +516,7 @@ module Bundler
# Missing summary is downgraded to a warning in later versions,
# so we set it to an empty string to prevent an exception here.
spec.summary ||= ""
- Bundler.ui.silence { spec.validate(false) }
- rescue Errno::ENOENT
- nil
+ RubygemsIntegration.instance_method(:validate).bind(self).call(spec)
end
end
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 90bbd13d..228ab61a 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -222,6 +222,10 @@ module Bundler
private
+ def build_extensions(installer)
+ super if Bundler.rubygems.spec_missing_extensions?(installer.spec)
+ end
+
def serialize_gemspecs_in(destination)
expanded_path = destination.expand_path(Bundler.root)
Dir["#{expanded_path}/#{@glob}"].each do |spec_path|
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 6bfd2e88..9790ba51 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -135,9 +135,12 @@ module Bundler
if File.directory?(expanded_path)
# We sort depth-first since `<<` will override the earlier-found specs
Dir["#{expanded_path}/#{@glob}"].sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
- next unless spec = Bundler.load_gemspec(file, :validate)
- spec.loaded_from = file.to_s
+ next unless spec = Bundler.load_gemspec(file)
spec.source = self
+ Bundler.rubygems.set_installed_by_version(spec)
+ # Validation causes extension_dir to be calculated, which depends
+ # on #source, so we validate here instead of load_gemspec
+ Bundler.rubygems.validate(spec)
index << spec
end
@@ -194,8 +197,7 @@ module Bundler
SharedHelpers.chdir(gem_dir) do
installer = Path::Installer.new(spec, :env_shebang => false)
run_hooks(:pre_install, installer)
- installer.build_extensions unless disable_extensions
- run_hooks(:post_build, installer)
+ build_extensions(installer) unless disable_extensions
installer.generate_bin
run_hooks(:post_install, installer)
end
@@ -213,6 +215,11 @@ module Bundler
Bundler.ui.warn "The validation message from Rubygems was:\n #{e.message}"
end
+ def build_extensions(installer)
+ installer.build_extensions
+ run_hooks(:post_build, installer)
+ end
+
def run_hooks(type, installer)
hooks_meth = "#{type}_hooks"
return unless Gem.respond_to?(hooks_meth)