summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/config.rb4
-rw-r--r--lib/bundler/cli/update.rb2
-rw-r--r--lib/bundler/dsl.rb2
-rw-r--r--lib/bundler/environment_preserver.rb1
-rw-r--r--lib/bundler/feature_flag.rb24
-rw-r--r--lib/bundler/rubygems_ext.rb12
-rw-r--r--lib/bundler/rubygems_integration.rb14
-rw-r--r--lib/bundler/self_manager.rb1
-rw-r--r--lib/bundler/source/git/git_proxy.rb2
-rw-r--r--lib/bundler/source/path.rb7
-rw-r--r--lib/bundler/source_map.rb2
-rw-r--r--lib/bundler/templates/newgem/github/workflows/main.yml.tt2
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/bundler_integration.rb23
-rw-r--r--lib/rubygems/request_set.rb9
-rw-r--r--lib/tempfile.rb2
-rw-r--r--lib/weakref.rb2
19 files changed, 83 insertions, 32 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index c0c7d9f899..198c9e2846 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -512,7 +512,7 @@ module Bundler
end
end
- unless Bundler.feature_flag.bundler_3_mode?
+ unless Bundler.feature_flag.bundler_4_mode?
desc "viz [OPTIONS]", "Generates a visual dependency graph", hide: true
long_desc <<-D
Viz generates a PNG file of the current Gemfile as a dependency graph.
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
index 77b502fe60..d963679085 100644
--- a/lib/bundler/cli/config.rb
+++ b/lib/bundler/cli/config.rb
@@ -26,8 +26,8 @@ module Bundler
end
message = "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
- removed_message = "Using the `config` command without a subcommand [list, get, set, unset] is has been removed. Use `bundle #{new_args.join(" ")}` instead."
- SharedHelpers.major_deprecation 3, message, removed_message: removed_message
+ removed_message = "Using the `config` command without a subcommand [list, get, set, unset] has been removed. Use `bundle #{new_args.join(" ")}` instead."
+ SharedHelpers.major_deprecation 4, message, removed_message: removed_message
Base.new(options, name, value, self).run
end
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index ab31d00879..ba3f1ec056 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -26,7 +26,7 @@ module Bundler
if Bundler.feature_flag.update_requires_all_flag?
raise InvalidOption, "To update everything, pass the `--all` flag."
end
- SharedHelpers.major_deprecation 3, "Pass --all to `bundle update` to update everything"
+ SharedHelpers.major_deprecation 4, "Pass --all to `bundle update` to update everything"
elsif !full_update && options[:all]
raise InvalidOption, "Cannot specify --all along with specific options."
end
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 8ebc3d0020..4f9fbc55b1 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -521,7 +521,7 @@ module Bundler
end
def multiple_global_source_warning
- if Bundler.feature_flag.bundler_3_mode?
+ if Bundler.feature_flag.bundler_4_mode?
msg = "This Gemfile contains multiple global sources. " \
"Each source after the first must include a block to indicate which gems " \
"should come from that source"
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb
index 444ab6fd37..ffffceb487 100644
--- a/lib/bundler/environment_preserver.rb
+++ b/lib/bundler/environment_preserver.rb
@@ -6,6 +6,7 @@ module Bundler
BUNDLER_KEYS = %w[
BUNDLE_BIN_PATH
BUNDLE_GEMFILE
+ BUNDLER_4_MODE
BUNDLER_VERSION
BUNDLER_SETUP
GEM_HOME
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index b19cf42cc3..38498b245f 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -27,20 +27,20 @@ module Bundler
(1..10).each {|v| define_method("bundler_#{v}_mode?") { @major_version >= v } }
- settings_flag(:allow_offline_install) { bundler_3_mode? }
- settings_flag(:auto_clean_without_path) { bundler_3_mode? }
- settings_flag(:cache_all) { bundler_3_mode? }
- settings_flag(:default_install_uses_path) { bundler_3_mode? }
- settings_flag(:forget_cli_options) { bundler_3_mode? }
- settings_flag(:global_gem_cache) { bundler_3_mode? }
- settings_flag(:lockfile_checksums) { bundler_3_mode? }
- settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
+ settings_flag(:allow_offline_install) { bundler_4_mode? }
+ settings_flag(:auto_clean_without_path) { bundler_4_mode? }
+ settings_flag(:cache_all) { bundler_4_mode? }
+ settings_flag(:default_install_uses_path) { bundler_4_mode? }
+ settings_flag(:forget_cli_options) { bundler_4_mode? }
+ settings_flag(:global_gem_cache) { bundler_4_mode? }
+ settings_flag(:lockfile_checksums) { bundler_4_mode? }
+ settings_flag(:path_relative_to_cwd) { bundler_4_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
- settings_flag(:print_only_version_number) { bundler_3_mode? }
- settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
- settings_flag(:update_requires_all_flag) { bundler_4_mode? }
+ settings_flag(:print_only_version_number) { bundler_4_mode? }
+ settings_flag(:setup_makes_kernel_gem_public) { !bundler_4_mode? }
+ settings_flag(:update_requires_all_flag) { bundler_5_mode? }
- settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
+ settings_option(:default_cli_command) { bundler_4_mode? ? :cli_help : :install }
def initialize(bundler_version)
@bundler_version = Gem::Version.create(bundler_version)
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 6777c78194..8cf3b56b83 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -283,6 +283,18 @@ module Gem
end
end
+ if Gem.rubygems_version < Gem::Version.new("3.5.22")
+ module FixPathSourceMissingExtensions
+ def missing_extensions?
+ return false if %w[Bundler::Source::Path Bundler::Source::Gemspec].include?(source.class.name)
+
+ super
+ end
+ end
+
+ prepend FixPathSourceMissingExtensions
+ end
+
private
def dependencies_to_gemfile(dependencies, group = nil)
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index eddf36278c..5342c3dbf9 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -222,8 +222,6 @@ module Bundler
# Used to give better error messages when activating specs outside of the current bundle
def replace_bin_path(specs_by_name)
- gem_class = (class << Gem; self; end)
-
redefine_method(gem_class, :find_spec_for_exe) do |gem_name, *args|
exec_name = args.first
raise ArgumentError, "you must supply exec_name" unless exec_name
@@ -345,9 +343,13 @@ module Bundler
Gem::Specification.all = specs
end
- redefine_method((class << Gem; self; end), :finish_resolve) do |*|
+ redefine_method(gem_class, :finish_resolve) do |*|
[]
end
+
+ redefine_method(gem_class, :load_plugins) do |*|
+ load_plugin_files specs.flat_map(&:plugins)
+ end
end
def plain_specs
@@ -447,6 +449,12 @@ module Bundler
def default_stubs
Gem::Specification.default_stubs("*.gemspec")
end
+
+ private
+
+ def gem_class
+ class << Gem; self; end
+ end
end
def self.rubygems
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index 72bcb264ab..ab16061dc7 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -105,6 +105,7 @@ module Bundler
def autoswitching_applies?
ENV["BUNDLER_VERSION"].nil? &&
+ ENV["BUNDLER_4_MODE"].nil? &&
ruby_can_restart_with_same_arguments? &&
lockfile_version
end
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index 1a7a0959c9..f613377cb2 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -408,7 +408,7 @@ module Bundler
def capture3_args_for(cmd, dir)
return ["git", *cmd] unless dir
- if Bundler.feature_flag.bundler_3_mode? || supports_minus_c?
+ if Bundler.feature_flag.bundler_4_mode? || supports_minus_c?
["git", "-C", dir.to_s, *cmd]
else
["git", *cmd, { chdir: dir.to_s }]
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 885dd96d85..ac76ae1fa0 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -167,6 +167,13 @@ module Bundler
next unless spec = load_gemspec(file)
spec.source = self
+ # The ignore attribute is for ignoring installed gems that don't
+ # have extensions correctly compiled for activation. In the case of
+ # path sources, there's a single version of each gem in the path
+ # source available to Bundler, so we always certainly want to
+ # consider that for activation and never makes sense to ignore it.
+ spec.ignored = false
+
# Validation causes extension_dir to be calculated, which depends
# on #source, so we validate here instead of load_gemspec
validate_spec(spec)
diff --git a/lib/bundler/source_map.rb b/lib/bundler/source_map.rb
index ca73e01f9d..a8e12d08c3 100644
--- a/lib/bundler/source_map.rb
+++ b/lib/bundler/source_map.rb
@@ -23,7 +23,7 @@ module Bundler
if previous_source.nil?
requirements[indirect_dependency_name] = source
else
- no_ambiguous_sources = Bundler.feature_flag.bundler_3_mode?
+ no_ambiguous_sources = Bundler.feature_flag.bundler_4_mode?
msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
diff --git a/lib/bundler/templates/newgem/github/workflows/main.yml.tt b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
index d1b5ae0534..9224ee0ca2 100644
--- a/lib/bundler/templates/newgem/github/workflows/main.yml.tt
+++ b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
@@ -18,6 +18,8 @@ jobs:
steps:
- uses: actions/checkout@v4
+ with:
+ persist-credentials: false
<%- if config[:ext] == 'rust' -%>
- name: Set up Ruby & Rust
uses: oxidize-rb/actions/setup-ruby-and-rust@v1
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index fa24b4966e..a995f4f281 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.7.0.dev".freeze
+ VERSION = (ENV["BUNDLER_4_MODE"] == "true" ? "4.0.0" : "2.7.0.dev").freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 1225cbe5cb..fc97f5ff25 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1144,7 +1144,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
require_relative "rubygems/user_interaction"
- require "bundler"
+ require_relative "rubygems/bundler_integration"
begin
Gem::DefaultUserInteraction.use_ui(ui) do
Bundler.ui.silence do
diff --git a/lib/rubygems/bundler_integration.rb b/lib/rubygems/bundler_integration.rb
new file mode 100644
index 0000000000..28228e2398
--- /dev/null
+++ b/lib/rubygems/bundler_integration.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require "bundler/version"
+
+if Bundler::VERSION > "2.6.9"
+ require "bundler"
+else
+ previous_platforms = {}
+
+ platform_const_list = ["JAVA", "MSWIN", "MSWIN64", "MINGW", "X64_MINGW_LEGACY", "X64_MINGW", "UNIVERSAL_MINGW", "WINDOWS", "X64_LINUX", "X64_LINUX_MUSL"]
+
+ platform_const_list.each do |platform|
+ previous_platforms[platform] = Gem::Platform.const_get(platform)
+ Gem::Platform.send(:remove_const, platform)
+ end
+
+ require "bundler"
+
+ platform_const_list.each do |platform|
+ Gem::Platform.send(:remove_const, platform) if Gem::Platform.const_defined?(platform)
+ Gem::Platform.const_set(platform, previous_platforms[platform])
+ end
+end
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index 875df7e019..5a855fdb10 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -181,13 +181,10 @@ class Gem::RequestSet
# Install requested gems after they have been downloaded
sorted_requests.each do |req|
- if req.installed?
+ if req.installed? && @always_install.none? {|spec| spec == req.spec.spec }
req.spec.spec.build_extensions
-
- if @always_install.none? {|spec| spec == req.spec.spec }
- yield req, nil if block_given?
- next
- end
+ yield req, nil if block_given?
+ next
end
spec =
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index f3213c5684..7292e72c25 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -29,7 +29,7 @@ require 'tmpdir'
# require 'tempfile'
#
# # Tempfile.create with a block
-# # The filename are choosen automatically.
+# # The filename are chosen automatically.
# # (You can specify the prefix and suffix of the filename by an optional argument.)
# Tempfile.create {|f|
# f.puts "foo"
diff --git a/lib/weakref.rb b/lib/weakref.rb
index f0a7e7b318..0a09f7f993 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -17,7 +17,7 @@ require "delegate"
#
class WeakRef < Delegator
- VERSION = "0.1.3"
+ VERSION = "0.1.4"
##
# RefError is raised when a referenced object has been recycled by the