Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/bundler/compatibility_guard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@
if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3")
abort "Bundler 2 requires Ruby 2.3 or later. Either install bundler 1 or update to a supported Ruby version."
end

if Gem::Version.new(Gem::VERSION.dup) < Gem::Version.new("2.5")
abort "Bundler 2 requires RubyGems 2.5 or later. Either install bundler 1 or update to a supported RubyGems version."
end
end
9 changes: 1 addition & 8 deletions lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,7 @@ def warn_on_incompatible_bundler_deps
end

def can_install_in_parallel?
if Bundler.rubygems.provides?(">= 2.1.0")
true
else
Bundler.ui.warn "RubyGems #{Gem::VERSION} is not threadsafe, so your "\
"gems will be installed one at a time. Upgrade to RubyGems 2.1.0 " \
"or higher to enable parallel gem installation."
false
end
true
end

def install_in_parallel(size, standalone, force = false)
Expand Down
10 changes: 3 additions & 7 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,9 @@ def print_major_deprecations!
next if gemfiles.empty?
break false if gemfiles.size == 1
end
if multiple_gemfiles && Bundler.bundler_major_version == 1
Bundler::SharedHelpers.major_deprecation 2, \
"gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
end

return if Bundler.rubygems.provides?(">= 2")
major_deprecation(2, "Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
return unless multiple_gemfiles && Bundler.bundler_major_version == 1
Bundler::SharedHelpers.major_deprecation 2, \
"gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
end

def trap(signal, override = false, &block)
Expand Down
42 changes: 17 additions & 25 deletions lib/bundler/stub_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ def self.from_stub(stub)

attr_accessor :stub, :ignored

# Pre 2.2.0 did not include extension_dir
# https://github.com/rubygems/rubygems/commit/9485ca2d101b82a946d6f327f4bdcdea6d4946ea
if Bundler.rubygems.provides?(">= 2.2.0")
def source=(source)
super
# Stub has no concept of source, which means that extension_dir may be wrong
# This is the case for git-based gems. So, instead manually assign the extension dir
return unless source.respond_to?(:extension_dir_name)
path = File.join(stub.extensions_dir, source.extension_dir_name)
stub.extension_dir = File.expand_path(path)
end
def source=(source)
super
# Stub has no concept of source, which means that extension_dir may be wrong
# This is the case for git-based gems. So, instead manually assign the extension dir
return unless source.respond_to?(:extension_dir_name)
path = File.join(stub.extensions_dir, source.extension_dir_name)
stub.extension_dir = File.expand_path(path)
end

def to_yaml
Expand All @@ -32,11 +28,9 @@ def to_yaml

# @!group Stub Delegates

if Bundler.rubygems.provides?(">= 2.3")
# This is defined directly to avoid having to load every installed spec
def missing_extensions?
stub.missing_extensions?
end
# This is defined directly to avoid having to load every installed spec
def missing_extensions?
stub.missing_extensions?
end

def activated
Expand All @@ -57,16 +51,14 @@ def full_gem_path
stub.full_gem_path || method_missing(:full_gem_path)
end

if Bundler.rubygems.provides?(">= 2.2.0")
def full_require_paths
stub.full_require_paths
end
def full_require_paths
stub.full_require_paths
end

# This is what we do in bundler/rubygems_ext
# full_require_paths is always implemented in >= 2.2.0
def load_paths
full_require_paths
end
# This is what we do in bundler/rubygems_ext
# full_require_paths is always implemented
def load_paths
full_require_paths
end

def loaded_from
Expand Down
17 changes: 1 addition & 16 deletions spec/bundler/friendly_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@
FileUtils.rm(Gem.configuration.config_file_name)
end

it "reports a relevant friendly error message", :rubygems => "< 2.5.0" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G

bundle :install, :env => { "DEBUG" => true }

expect(out).to include("Your RubyGems configuration")
expect(out).to include("invalid YAML syntax")
expect(out).to include("Psych::SyntaxError")
expect(out).not_to include("ERROR REPORT TEMPLATE")
expect(exitstatus).to eq(25) if exitstatus
end

it "reports a relevant friendly error message", :rubygems => ">= 2.5.0" do
it "reports a relevant friendly error message" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
Expand Down
4 changes: 2 additions & 2 deletions spec/bundler/installer/gem_installer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
subject { described_class.new(spec, installer) }

context "spec_settings is nil" do
it "invokes install method with empty build_args", :rubygems => ">= 2" do
it "invokes install method with empty build_args" do
allow(spec_source).to receive(:install).with(spec, :force => false, :ensure_builtin_gems_cached => false, :build_args => [])
subject.install_from_spec
end
end

context "spec_settings is build option" do
it "invokes install method with build_args", :rubygems => ">= 2" do
it "invokes install method with build_args" do
allow(Bundler.settings).to receive(:[]).with(:bin)
allow(Bundler.settings).to receive(:[]).with(:inline)
allow(Bundler.settings).to receive(:[]).with(:forget_cli_options)
Expand Down
22 changes: 5 additions & 17 deletions spec/bundler/rubygems_integration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Bundler::RubygemsIntegration do
it "uses the same chdir lock as rubygems", :rubygems => "2.1" do
it "uses the same chdir lock as rubygems" do
expect(Bundler.rubygems.ext_lock).to eq(Gem::Ext::Builder::CHDIR_MONITOR)
end

Expand All @@ -15,30 +15,18 @@
end
subject { Bundler.rubygems.validate(spec) }

it "skips overly-strict gemspec validation", :rubygems => "< 1.7" do
expect(spec).to_not receive(:validate)
subject
end

it "validates with packaging mode disabled", :rubygems => "1.7" do
it "validates with packaging mode disabled" do
expect(spec).to receive(:validate).with(false)
subject
end

it "should set a summary to avoid an overly-strict error", :rubygems => "~> 1.7.0" do
spec.summary = nil
expect { subject }.not_to raise_error
expect(spec.summary).to eq("")
end

context "with an invalid spec" do
before do
expect(spec).to receive(:validate).with(false).
and_raise(Gem::InvalidSpecificationException.new("TODO is not an author"))
end

it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message",
:rubygems => "1.7" do
it "should raise a Gem::InvalidSpecificationException and produce a helpful warning message" do
expect { subject }.to raise_error(Gem::InvalidSpecificationException,
"The gemspec at #{__FILE__} is not valid. "\
"Please fix this gemspec.\nThe validation error was 'TODO is not an author'\n")
Expand All @@ -53,7 +41,7 @@
end
end

describe "#download_gem", :rubygems => ">= 2.0" do
describe "#download_gem" do
let(:bundler_retry) { double(Bundler::Retry) }
let(:retry) { double("Bundler::Retry") }
let(:uri) { URI.parse("https://foo.bar") }
Expand All @@ -78,7 +66,7 @@
end
end

describe "#fetch_all_remote_specs", :rubygems => ">= 2.0" do
describe "#fetch_all_remote_specs" do
let(:uri) { URI("https://example.com") }
let(:fetcher) { double("gem_remote_fetcher") }
let(:specs_response) { Marshal.dump(["specs"]) }
Expand Down
10 changes: 4 additions & 6 deletions spec/bundler/stub_specification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
described_class.from_stub(gemspec)
end

if Bundler.rubygems.provides?(">= 2.1")
describe "#from_stub" do
it "returns the same stub if already a Bundler::StubSpecification" do
stub = described_class.from_stub(with_bundler_stub_spec)
expect(stub).to be(with_bundler_stub_spec)
end
describe "#from_stub" do
it "returns the same stub if already a Bundler::StubSpecification" do
stub = described_class.from_stub(with_bundler_stub_spec)
expect(stub).to be(with_bundler_stub_spec)
end
end
end
4 changes: 2 additions & 2 deletions spec/commands/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def should_not_have_gems(*gems)
should_not_have_gems "foo-1.0"
end

it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo, :rubygems => "2.2" do
it "doesn't remove extensions artifacts from bundled git gems after clean", :ruby_repo do
build_git "very_simple_git_binary", &:add_c_extension

revision = revision_for(lib_path("very_simple_git_binary-1.0"))
Expand All @@ -736,7 +736,7 @@ def should_not_have_gems(*gems)
expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist
end

it "removes extension directories", :ruby_repo, :rubygems => "2.2" do
it "removes extension directories", :ruby_repo do
gemfile <<-G
source "file://#{gem_repo1}"

Expand Down
18 changes: 2 additions & 16 deletions spec/commands/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
expect(err).to include("bundler: exec needs a command to run")
end

it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo, :rubygems => ">= 2.5.2" do
it "raises a helpful error when exec'ing to something outside of the bundle", :ruby_repo do
bundle! "config clean false" # want to keep the rackup binstub
install_gemfile! <<-G
source "file://#{gem_repo1}"
Expand All @@ -237,20 +237,6 @@
end
end

# Different error message on old RG versions (before activate_bin_path) because they
# called `Kernel#gem` directly
it "raises a helpful error when exec'ing to something outside of the bundle", :rubygems => "< 2.5.2" do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "with_license"
G
[true, false].each do |l|
bundle! "config disable_exec_load #{l}"
bundle "exec rackup"
expect(last_command.stderr).to include "rack is not part of the bundle. Add it to your Gemfile."
end
end

describe "with help flags" do
each_prefix = proc do |string, &blk|
1.upto(string.length) {|l| blk.call(string[0, l]) }
Expand Down Expand Up @@ -444,7 +430,7 @@
end

describe "with gems bundled via :path with invalid gemspecs", :ruby_repo do
it "outputs the gemspec validation errors", :rubygems => ">= 1.7.2" do
it "outputs the gemspec validation errors" do
build_lib "foo"

gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
Expand Down
9 changes: 0 additions & 9 deletions spec/commands/help_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
# frozen_string_literal: true

RSpec.describe "bundle help" do
# RubyGems 1.4+ no longer load gem plugins so this test is no longer needed
it "complains if older versions of bundler are installed", :rubygems => "< 1.4" do
system_gems "bundler-0.8.1"

bundle "help"
expect(err).to include("older than 0.9")
expect(err).to include("running `gem cleanup bundler`.")
end

it "uses mann when available" do
with_fake_man do
bundle "help gemfile"
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
expect(err).not_to include("file://")
end

it "fails gracefully when downloading an invalid specification from the full index", :rubygems => "2.5" do
it "fails gracefully when downloading an invalid specification from the full index" do
build_repo2 do
build_gem "ajp-rails", "0.0.0", :gemspec => false, :skip_validation => true do |s|
bad_deps = [["ruby-ajp", ">= 0.2.0"], ["rails", ">= 0.14"]]
Expand Down
6 changes: 3 additions & 3 deletions spec/commands/newgem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def create_temporary_dir(dir)
it_should_behave_like "git config is absent"
end

it "sets gemspec metadata['allowed_push_host']", :rubygems => "2.0" do
it "sets gemspec metadata['allowed_push_host']" do
expect(generated_gem.gemspec.metadata["allowed_push_host"]).
to match(/mygemserver\.com/)
end
Expand Down Expand Up @@ -381,7 +381,7 @@ def create_temporary_dir(dir)
expect(bundled_app("test_gem/spec/spec_helper.rb")).to exist
end

it "depends on a specific version of rspec", :rubygems => ">= 1.8.1" do
it "depends on a specific version of rspec" do
rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "rspec" }
expect(rspec_dep).to be_specific
end
Expand Down Expand Up @@ -431,7 +431,7 @@ def create_temporary_dir(dir)
bundle "gem #{gem_name} --test=minitest"
end

it "depends on a specific version of minitest", :rubygems => ">= 1.8.1" do
it "depends on a specific version of minitest" do
rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "minitest" }
expect(rspec_dep).to be_specific
end
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
expect(out).to include("foo (1.0 #{sha[0..6]})")
end

it "handles when a version is a '-' prerelease", :rubygems => "2.1" do
it "handles when a version is a '-' prerelease" do
@git = build_git("foo", "1.0.0-beta.1", :path => lib_path("foo"))
install_gemfile <<-G
gem "foo", "1.0.0-beta.1", :git => "#{lib_path("foo")}"
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gemfile/gemspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
expect(the_bundle).to include_gems "foo 1.0.0"
end

it "does not break Gem.finish_resolve with conflicts", :rubygems => ">= 2" do
it "does not break Gem.finish_resolve with conflicts" do
build_lib("foo", :path => tmp.join("foo")) do |s|
s.version = "1.0.0"
s.add_dependency "bar", "= 1.0.0"
Expand Down
6 changes: 3 additions & 3 deletions spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@
expect(out).not_to include("gem install foo")
end

it "does not reinstall the extension", :ruby_repo, :rubygems => ">= 2.3.0" do
it "does not reinstall the extension", :ruby_repo do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
Expand Down Expand Up @@ -1247,7 +1247,7 @@
expect(out).to eq(installed_time)
end

it "does not reinstall the extension when changing another gem", :rubygems => ">= 2.3.0" do
it "does not reinstall the extension when changing another gem" do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
Expand Down Expand Up @@ -1290,7 +1290,7 @@
expect(out).to eq(installed_time)
end

it "does reinstall the extension when changing refs", :rubygems => ">= 2.3.0" do
it "does reinstall the extension when changing refs" do
build_git "foo" do |s|
s.add_dependency "rake"
s.extensions << "Rakefile"
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gemfile/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
expect(the_bundle).to include_gems "premailer 1.0.0"
end

it "warns on invalid specs", :rubygems => "1.7" do
it "warns on invalid specs" do
build_lib "foo"

gemspec = lib_path("foo-1.0").join("foo.gemspec").to_s
Expand Down
2 changes: 1 addition & 1 deletion spec/install/gems/compact_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def start
E
end

describe "checksum validation", :rubygems => ">= 2.3.0" do
describe "checksum validation" do
it "raises when the checksum does not match" do
install_gemfile <<-G, :artifice => "compact_index_wrong_gem_checksum"
source "#{source_uri}"
Expand Down
Loading