Skip to content
Browse files

Merge tag 'v1.2.2'

Version 1.2.2

Conflicts:
	.travis.yml
	lib/bundler.rb
	lib/bundler/psyched_yaml.rb
	lib/bundler/version.rb
	spec/bundler/psyched_yaml_spec.rb
	spec/other/clean_spec.rb
  • Loading branch information...
2 parents c9042b2 + 8d6f35a commit 42e5af3d237108dbbad0720237660974c4fd784e @indirect indirect committed Nov 15, 2012
View
29 .travis.yml
@@ -2,6 +2,8 @@ before_script:
- sudo apt-get install groff -y
- rake spec:deps
+# Rubygems versions MUST be available as rake tasks
+# see Rakefile:66 for the list of possible RGV values
env:
- RGV=v1.3.6
- RGV=v1.3.7
@@ -15,30 +17,33 @@ language: ruby
matrix:
exclude:
- - rvm: 1.9.2
+ # 2.0.0-preview1 shipped with Rubygems 1.8.24, so start there.
+ - rvm: 2.0.0-preview1
env: RGV=v1.3.6
- - rvm: 1.9.2
+ - rvm: 2.0.0-preview1
env: RGV=v1.3.7
- - rvm: 1.9.2
+ - rvm: 2.0.0-preview1
env: RGV=v1.4.2
+ - rvm: 2.0.0-preview1
+ env: RGV=v1.5.3
+ - rvm: 2.0.0-preview1
+ env: RGV=v1.6.2
+ - rvm: 2.0.0-preview1
+ env: RGV=v1.7.2
+ # 1.9.3 shipped with Rubygems 1.3.7.1, and 1.4 was 1.8-only
- rvm: 1.9.3
env: RGV=v1.3.6
- rvm: 1.9.3
env: RGV=v1.3.7
- rvm: 1.9.3
env: RGV=v1.4.2
- - rvm: 2.0.0
+ # 1.9.2 shipped with Rubygems 1.3.7, and 1.4 was 1.8-only
+ - rvm: 1.9.2
env: RGV=v1.3.6
- - rvm: 2.0.0
+ - rvm: 1.9.2
env: RGV=v1.3.7
- - rvm: 2.0.0
+ - rvm: 1.9.2
env: RGV=v1.4.2
- - rvm: 2.0.0
- env: RGV=v1.5.3
- - rvm: 2.0.0
- env: RGV=v1.6.2
- - rvm: 2.0.0
- env: RGV=v1.7.2
notifications:
email:
View
15 CHANGELOG.md
@@ -1,3 +1,18 @@
+## 1.2.2 (Nov 14, 2012)
+
+Bugfixes:
+
+ - support new Psych::SyntaxError for Ruby 2.0.0 (@tenderlove, @sol)
+ - `bundle viz` works with git gems again (@hirochachacha)
+ - recognize more cases when OpenSSL is not present
+
+## 1.2.1 (Sep 19, 2012)
+
+Bugfixes:
+
+ - `bundle clean` now works with BUNDLE_WITHOUT groups again
+ - have a net/http read timeout around the Gemcutter API Endpoint
+
## 1.2.0 (Aug 30, 2012)
Bugfixes:
View
2 lib/bundler.rb
@@ -295,7 +295,7 @@ def load_gemspec_uncached(file)
Gem::Specification.from_yaml(contents)
# Raises ArgumentError if the file is not valid YAML (on syck)
# Psych raises a Psych::SyntaxError
- rescue ArgumentError, YamlSyntaxError, Gem::EndOfYAMLException, Gem::Exception
+ rescue YamlSyntaxError, Gem::EndOfYAMLException, Gem::Exception
eval_gemspec(path, contents)
end
else
View
10 lib/bundler/definition.rb
@@ -31,7 +31,7 @@ def self.build(gemfile, lockfile, unlock)
specs, then we can try to resolve locally.
=end
- def initialize(lockfile, dependencies, sources, unlock, ruby_version = "")
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil)
@unlocking = unlock == true || !unlock.empty?
@dependencies, @sources, @unlock = dependencies, sources, unlock
@@ -109,9 +109,9 @@ def resolve_remotely!
specs
end
- def specs(deps = requested_dependencies)
+ def specs
@specs ||= begin
- specs = resolve.materialize(deps)
+ specs = resolve.materialize(requested_dependencies)
unless specs["bundler"].any?
local = Bundler.settings[:frozen] ? rubygems_index : index
@@ -131,10 +131,6 @@ def removed_specs
@locked_specs - specs
end
- def all_specs
- specs(dependencies)
- end
-
def new_platform?
@new_platform
end
View
14 lib/bundler/fetcher.rb
@@ -6,6 +6,8 @@ module Bundler
# Handles all the fetching with the rubygems server
class Fetcher
REDIRECT_LIMIT = 5
+ # how long to wait for each gemcutter API call
+ API_TIMEOUT = 10
attr_reader :has_api
@@ -45,6 +47,7 @@ def initialize(remote_uri)
@remote_uri = remote_uri
@has_api = true # will be set to false if the rubygems index is ever fetched
@@connection ||= Net::HTTP::Persistent.new nil, :ENV
+ @@connection.read_timeout = API_TIMEOUT
end
# fetch a gem specification
@@ -105,16 +108,6 @@ def specs(gem_names, source)
end
index
- rescue LoadError => e
- if e.message.include?("cannot load such file -- openssl")
- raise InstallError,
- "\nCould not load OpenSSL." \
- "\nYou must recompile Ruby with OpenSSL support or change the sources in your" \
- "\nGemfile from 'https' to 'http'. Instructions for compiling with OpenSSL" \
- "\nusing RVM are available at rvm.io/packages/openssl."
- else
- raise e
- end
end
# fetch index
@@ -143,6 +136,7 @@ def fetch(uri, counter = 0)
begin
Bundler.ui.debug "Fetching from: #{uri}"
+ response = nil
response = @@connection.request(uri)
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT,
EOFError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
View
13 lib/bundler/friendly_errors.rb
@@ -12,6 +12,19 @@ def self.with_friendly_errors
exit 1
rescue SystemExit => e
exit e.status
+ rescue LoadError => e
+ case e.message
+ when /cannot load such file -- openssl/, /openssl.so/, /libcrypto.so/
+ Bundler.ui.error "\nCould not load OpenSSL."
+ Bundler.ui.warn "You must recompile Ruby with OpenSSL support or change the sources in your" \
+ "\nGemfile from 'https' to 'http'. Instructions for compiling with OpenSSL" \
+ "\nusing RVM are available at rvm.io/packages/openssl."
+ Bundler.ui.debug "#{e.class}: #{e.message}"
+ Bundler.ui.debug e.backtrace.join("\n")
+ exit 1
+ else
+ raise e
+ end
rescue Exception => e
Bundler.ui.error(
"Unfortunately, a fatal error has occurred. Please see the Bundler \n" \
View
25 lib/bundler/graph.rb
@@ -15,6 +15,7 @@ def initialize(env, output_file, show_version = false, show_requirements = false
@node_options = {}
@edge_options = {}
+ _patching_gem_dependency_class
_populate_relations
end
@@ -27,7 +28,6 @@ def viz
private
def _populate_relations
- relations = Hash.new {|h, k| h[k] = Set.new}
parent_dependencies = _groups.values.to_set.flatten
while true
if parent_dependencies.empty?
@@ -36,7 +36,6 @@ def _populate_relations
tmp = Set.new
parent_dependencies.each do |dependency|
child_dependencies = dependency.to_spec.runtime_dependencies.to_set
- relations[dependency.name] += child_dependencies.to_set
@relations[dependency.name] += child_dependencies.map(&:name).to_set
tmp += child_dependencies
@@ -48,7 +47,6 @@ def _populate_relations
parent_dependencies = tmp
end
end
- @relations
end
def _groups
@@ -87,6 +85,27 @@ def _make_label(symbol_or_string_or_dependency, element_type)
label.nil? ? {} : { :label => label }
end
+ def _patching_gem_dependency_class
+ # method borrow from rubygems/dependency.rb
+ # redefinition of matching_specs will also redefine to_spec and to_specs
+ Gem::Dependency.class_eval do
+ def matching_specs platform_only = false
+ matches = Bundler.load.specs.select { |spec|
+ self.name === spec.name and # TODO: == instead of ===
+ requirement.satisfied_by? spec.version
+ }
+
+ if platform_only
+ matches.reject! { |spec|
+ not Gem::Platform.match spec.platform
+ }
+ end
+
+ matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
+ end
+ end
+ end
+
class GraphVizClient
def initialize(graph_instance)
@graph_name = graph_instance.class::GRAPH_NAME
View
29 lib/bundler/psyched_yaml.rb
@@ -1,23 +1,26 @@
-# Psych could be a gem
+# Psych could be a gem, so try to ask for it
begin
gem 'psych'
-rescue Gem::LoadError
-end if defined?(Gem)
+rescue LoadError
+end if defined?(gem)
-# Psych from stdlib, but only if Syck isn't loaded
+# Psych could just be in the stdlib
+# but it's too late if Syck is already loaded
begin
- require 'psych'
+ require 'psych' unless defined?(Syck)
rescue LoadError
-end unless defined?(Syck)
+ # Apparently Psych wasn't available. Oh well.
+end
-# Psych might NOT EXIST AT ALL, so fall back on yaml
+# At least load the YAML stdlib, whatever that may be
require 'yaml' unless defined?(YAML)
module Bundler
- # now we need a unified Yaml syntax error
- if defined?(Psych::SyntaxError) # Psych
- YamlSyntaxError = Psych::SyntaxError
- else # Syck just raises an ArgmuentError
- YamlSyntaxError = ArgumentError
+ # On encountering invalid YAML,
+ # Psych raises Psych::SyntaxError
+ if defined?(::Psych::SyntaxError)
+ YamlSyntaxError = ::Psych::SyntaxError
+ else # Syck raises ArgumentError
+ YamlSyntaxError = ::ArgumentError
end
-end
+end
View
4 lib/bundler/runtime.rb
@@ -123,12 +123,12 @@ def clean
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
spec_gem_paths = []
# need to keep git sources around
- spec_git_paths = []
+ spec_git_paths = @definition.sources.select {|s| s.is_a?(Bundler::Source::Git) }.map {|s| s.path.to_s }
spec_git_cache_dirs = []
spec_gem_executables = []
spec_cache_paths = []
spec_gemspec_paths = []
- @definition.all_specs.each do |spec|
+ specs.each do |spec|
spec_gem_paths << spec.full_gem_path
# need to check here in case gems are nested like for the rails git repo
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
View
19 spec/bundler/bundler_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+require 'bundler'
+
+describe Bundler do
+ describe "#load_gemspec_uncached" do
+ it "should catch Psych syntax errors" do
+ gemspec = <<-GEMSPEC
+{:!00 ao=gu\g1= 7~f
+GEMSPEC
+ File.open(tmp("test.gemspec"), 'wb') do |file|
+ file.puts gemspec
+ end
+
+ proc {
+ Bundler.load_gemspec_uncached(tmp("test.gemspec"))
+ }.should raise_error(Bundler::GemspecError)
+ end
+ end
+end
View
44 spec/install/gems/dependency_api_spec.rb
@@ -158,6 +158,50 @@
expect(out).to match(/Too many redirects/)
end
+ context "when Gemcutter API takes too long to respond" do
+ let(:port) { 2000 }
+ let(:server_uri) { "http://localhost:2000" }
+
+ before do
+ # need to hack, so we can require rack
+ old_gem_home = ENV['GEM_HOME']
+ ENV['GEM_HOME'] = Spec::Path.base_system_gems.to_s
+ require 'rack'
+ ENV['GEM_HOME'] = old_gem_home
+
+ require File.expand_path('../../../support/artifice/endpoint_timeout', __FILE__)
+ require 'thread'
+ @t = Thread.new {
+ server = Rack::Server.start(:app => EndpointTimeout,
+ :Host => '0.0.0.0',
+ :Port => port,
+ :server => 'webrick',
+ :AccessLog => [])
+ server.start
+ }
+ @t.run
+
+ # ensure server is started
+ require 'timeout'
+ Timeout.timeout(15) { sleep(0.1) until @t.status == "sleep" }
+ end
+
+ after do
+ @t.kill
+ end
+
+ it "times out and falls back on the modern index" do
+ gemfile <<-G
+ source "#{server_uri}"
+ gem "rack"
+ G
+
+ bundle :install
+ out.should include("\nFetching full source index from #{server_uri}")
+ should_be_installed "rack 1.0.0"
+ end
+ end
+
context "when --full-index is specified" do
it "should use the modern index for install" do
gemfile <<-G
View
40 spec/other/clean_spec.rb
@@ -100,6 +100,29 @@ def should_not_have_gems(*gems)
expect(vendored_gems("bin/rackup")).to exist
end
+ it "remove gems in bundle without groups" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "foo"
+
+ group :test_group do
+ gem "rack", "1.0.0"
+ end
+ G
+
+ bundle "install --path vendor/bundle"
+ bundle "install --without test_group"
+ bundle :clean
+
+ out.should eq("Removing rack (1.0.0)")
+
+ should_have_gems 'foo-1.0'
+ should_not_have_gems 'rack-1.0.0'
+
+ vendored_gems("bin/rackup").should_not exist
+ end
+
it "does not remove cached git dir if it's being used" do
build_git "foo"
revision = revision_for(lib_path("foo-1.0"))
@@ -234,6 +257,23 @@ def should_not_have_gems(*gems)
expect(vendored_gems("cache/bundler/git/foo-#{digest}")).to exist
end
+ it "does not blow up when using without groups" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "rack"
+
+ group :development do
+ gem "foo"
+ end
+ G
+
+ bundle "install --path vendor/bundle --without development"
+
+ bundle :clean, :exitstatus => true
+ exitstatus.should == 0
+ end
+
it "displays an error when used without --path" do
install_gemfile <<-G
source "file://#{gem_repo1}"
View
13 spec/other/platform_spec.rb
@@ -158,6 +158,19 @@
expect(exitstatus).not_to eq(0)
end
+
+ it "should print if no ruby version is specified" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+
+ gem "foo"
+ G
+
+ bundle "platform --ruby"
+ puts err
+
+ out.should eq("No ruby version specified")
+ end
end
let(:ruby_version_correct) { "ruby \"#{RUBY_VERSION}\", :engine => \"#{local_ruby_engine}\", :engine_version => \"#{local_engine_version}\"" }
View
13 spec/support/artifice/endpoint_timeout.rb
@@ -0,0 +1,13 @@
+require File.expand_path("../endpoint_fallback", __FILE__)
+
+Artifice.deactivate
+
+class EndpointTimeout < EndpointFallback
+ SLEEP_TIMEOUT = 15
+
+ get "/api/v1/dependencies" do
+ sleep(SLEEP_TIMEOUT)
+ end
+end
+
+Artifice.activate_with(EndpointTimeout)
View
3 spec/support/rubygems_ext.rb
@@ -11,13 +11,14 @@ def self.setup
unless File.exist?("#{Path.base_system_gems}")
FileUtils.mkdir_p(Path.base_system_gems)
- puts "fetching fakeweb, artifice, sinatra, rake, and builder for the tests to use..."
+ puts "fetching fakeweb, artifice, sinatra, rake, rack, and builder for the tests to use..."
`gem install fakeweb artifice --no-rdoc --no-ri`
`gem install sinatra --version 1.2.7 --no-rdoc --no-ri`
# Rake version has to be consistent for tests to pass
`gem install rake --version 0.8.7 --no-rdoc --no-ri`
# 3.0.0 breaks 1.9.2 specs
`gem install builder --version 2.1.2 --no-rdoc --no-ri`
+ `gem install rack --no-rdoc --no-ri`
end
ENV['HOME'] = Path.home.to_s

0 comments on commit 42e5af3

Please sign in to comment.
Something went wrong with that request. Please try again.