Skip to content
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 4.0.22 / 2026-09-30

### Enhancements:

* Add --source option to gem exec command. Pull request [#9765](https://github.com/ruby/rubygems/pull/9765) by Akshay Birajdar and Akshay Birajdar
* Keep credentials on redirects only within the same origin. Pull request [#9909](https://github.com/ruby/rubygems/pull/9909) by Hiroshi SHIBATA
* Validate the version field in Gem::Installer#verify_spec. Pull request [#9890](https://github.com/ruby/rubygems/pull/9890) by Hiroshi SHIBATA
* Installs bundler 4.0.22 as a default gem.

### Bug fixes:

* Remove the build_info file on uninstall and stop gem build from logging unknown extensions. Pull request [#9894](https://github.com/ruby/rubygems/pull/9894) by Hiroshi SHIBATA

## 4.0.21 / 2026-09-16

### Enhancements:
Expand Down
17 changes: 17 additions & 0 deletions bundler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 4.0.22 / 2026-09-30

### Enhancements:

* Report the effective platform in `bundle platform`. Pull request [#9898](https://github.com/ruby/rubygems/pull/9898) by Islam Elsayed
* Keep credentials on redirects only within the same origin. Pull request [#9909](https://github.com/ruby/rubygems/pull/9909) by Hiroshi SHIBATA
* Update Magnus version in Rust extension gem template. Pull request [#9904](https://github.com/ruby/rubygems/pull/9904) by Mat Sadler and Hiroshi SHIBATA

### Bug fixes:

* Stop `Bundler.bin_path` creating the directory it reports. Pull request [#9887](https://github.com/ruby/rubygems/pull/9887) by Islam Elsayed and Hiroshi SHIBATA
* Look up `bundler-<command>` executables only in PATH. Pull request [#9874](https://github.com/ruby/rubygems/pull/9874) by Hiroshi SHIBATA

### Documentation:

* Describe `--major` as preferring the latest major version. Pull request [#9891](https://github.com/ruby/rubygems/pull/9891) by Hiroshi SHIBATA

## 4.0.21 / 2026-09-16

### Enhancements:
Expand Down
4 changes: 1 addition & 3 deletions bundler/lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ def configured_bundle_path
def bin_path
@bin_path ||= begin
path = Bundler.settings[:bin] || "bin"
path = Pathname.new(path).expand_path(root).expand_path
mkdir_p(path)
path
Pathname.new(path).expand_path(root).expand_path
end
end

Expand Down
22 changes: 17 additions & 5 deletions bundler/lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def help(cli = nil)
else
puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
end
elsif command_path = Bundler.which("bundler-#{cli}")
elsif command_path = self.class.bundler_command_path(cli)
Kernel.exec(command_path, "--help")
else
super
Expand All @@ -189,11 +189,23 @@ def self.handle_no_command_error(command, has_namespace = $thor_runner)
return Bundler::Plugin.exec_command(command, ARGV[1..-1])
end

return super unless command_path = Bundler.which("bundler-#{command}")
return super unless command_path = bundler_command_path(command)

Kernel.exec(command_path, *ARGV[1..-1])
end

# Only PATH is searched, unlike Bundler.which, which also finds a file in
# the current directory and returns a bare name that Kernel.exec cannot run.
def self.bundler_command_path(command)
ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).each do |path|
path = path[1..-2] if path.start_with?('"') && path.end_with?('"')
command_path = Bundler.find_executable(File.expand_path("bundler-#{command}", path))
return command_path if command_path
end

nil
end

desc "init [OPTIONS]", "Generates a Gemfile into the current working directory"
long_desc <<-D
Init generates a default Gemfile in the current working directory. When adding a
Expand Down Expand Up @@ -320,7 +332,7 @@ def install
method_option "bundler", type: :string, lazy_default: ">= #{Bundler::VERSION}", banner: "Update the locked version of bundler"
method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
method_option "major", type: :boolean, banner: "Prefer updating to latest major version (default)"
method_option "pre", type: :boolean, banner: "Always choose the highest allowed version when updating gems, regardless of prerelease status"
method_option "strict", type: :boolean, banner: "Do not allow any gem to be updated past latest --patch | --minor | --major"
method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
Expand Down Expand Up @@ -431,7 +443,7 @@ def add(*gems)
method_option "filter-strict", type: :boolean, aliases: "--strict", banner: "Only list newer versions allowed by your Gemfile requirements"
method_option "update-strict", type: :boolean, banner: "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
method_option "major", type: :boolean, banner: "Prefer updating to latest major version (default)"
method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
method_option "filter-major", type: :boolean, banner: "Only list major newer versions"
method_option "filter-minor", type: :boolean, banner: "Only list minor newer versions"
Expand Down Expand Up @@ -638,7 +650,7 @@ def inject(*)
method_option "normalize-platforms", type: :boolean, default: false, banner: "Normalize lockfile platforms"
method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
method_option "major", type: :boolean, banner: "If updating, prefer updating to latest major version (default)"
method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
Expand Down
16 changes: 15 additions & 1 deletion bundler/lib/bundler/cli/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def run
else
platforms = Bundler.definition.platforms.map {|p| "* #{p}" }

output << "Your platform is: #{Gem::Platform.local}"
output << platform_info
output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"

if ruby_version
Expand All @@ -44,5 +44,19 @@ def run

Bundler.ui.info output.join("\n\n")
end

private

def platform_info
info = "Your platform is: #{Gem::Platform.local}"
return info if Bundler.local_platform == Gem::Platform.local

info + "\nHowever, your effective platform is: #{Bundler.local_platform} " \
"(because force_ruby_platform is #{force_ruby_platform_origin})"
end

def force_ruby_platform_origin
Bundler.settings.pretty_values_for(:force_ruby_platform).first.sub(/\ASet /, "set ")
end
end
end
2 changes: 1 addition & 1 deletion bundler/lib/bundler/fetcher/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def fetch(uri, headers = {}, counter = 0)
if https?(uri) && !https?(new_uri)
raise HTTPError, "Redirecting to a non-https URI is not allowed: #{URICredentialsFilter.credential_filtered_uri(new_uri)}"
end
if new_uri.host == uri.host
if [new_uri.scheme, new_uri.host, new_uri.port] == [uri.scheme, uri.host, uri.port]
new_uri.user = uri.user
new_uri.password = uri.password
end
Expand Down
4 changes: 4 additions & 0 deletions bundler/lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def generate_bundler_executable_stubs(spec, options = {})
template_path = File.expand_path("templates/Executable", __dir__)
template = File.read(template_path)

Bundler.mkdir_p(bin_path)

exists = []
spec.executables.each do |executable|
binstub_path = "#{bin_path}/#{executable}"
Expand Down Expand Up @@ -173,6 +175,8 @@ def generate_standalone_bundler_executable_stubs(spec, options = {})
ruby_command = Thor::Util.ruby_command
ruby_command = ruby_command

Bundler.mkdir_p(bin_path)

spec.executables.each do |executable|
next if executable == "bundle"
executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/man/bundle-lock.1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ If updating, prefer updating only to next patch version\.
If updating, prefer updating only to next minor version\.
.TP
\fB\-\-major\fR
If updating, prefer updating to next major version (default)\.
If updating, prefer updating to latest major version (default)\.
.TP
\fB\-\-pre\fR
If updating, always choose the highest allowed version, regardless of prerelease status\.
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/man/bundle-lock.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Lock the gems specified in Gemfile.
If updating, prefer updating only to next minor version.

* `--major`:
If updating, prefer updating to next major version (default).
If updating, prefer updating to latest major version (default).

* `--pre`:
If updating, always choose the highest allowed version, regardless of prerelease status.
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/man/bundle-outdated.1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ List gems organized by groups\.
Prefer updating only to next minor version\.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
Prefer updating to latest major version (default)\.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/man/bundle-outdated.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
Prefer updating only to next minor version.

* `--major`:
Prefer updating to next major version (default).
Prefer updating to latest major version (default).

* `--patch`:
Prefer updating only to next patch version.
Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/man/bundle-update.1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Prefer updating only to next patch version\.
Prefer updating only to next minor version\.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
Prefer updating to latest major version (default)\.
.TP
\fB\-\-pre\fR
Always choose the highest allowed version, regardless of prerelease status\.
Expand Down Expand Up @@ -175,7 +175,7 @@ Prefer updating only to next patch version\.
Prefer updating only to next minor version\.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
Prefer updating to latest major version (default)\.
.TP
\fB\-\-strict\fR
Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/man/bundle-update.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ gem.
Prefer updating only to next minor version.

* `--major`:
Prefer updating to next major version (default).
Prefer updating to latest major version (default).

* `--pre`:
Always choose the highest allowed version, regardless of prerelease status.
Expand Down Expand Up @@ -238,7 +238,7 @@ versions are resolved. One of the following options can be used: `--patch`,
Prefer updating only to next minor version.

* `--major`:
Prefer updating to next major version (default).
Prefer updating to latest major version (default).

* `--strict`:
Do not allow any gem to be updated past latest `--patch` | `--minor` | `--major`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
magnus = { version = "0.8.2" }
magnus = { version = "0.9" }
rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion bundler/lib/bundler/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: false

module Bundler
VERSION = "4.0.21".freeze
VERSION = "4.0.22".freeze

def self.bundler_major_version
@bundler_major_version ||= gem_version.segments.first
Expand Down
19 changes: 19 additions & 0 deletions bundler/spec/bundler/bundler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@
end
end

describe "#bin_path" do
it "returns the path without creating the directory" do
allow(Bundler).to receive(:root).and_return(bundled_app)
Bundler.reset_paths!

expect(Bundler.bin_path).to eq(bundled_app("bin"))
expect(bundled_app("bin")).not_to exist
end

it "does not touch the filesystem" do
allow(Bundler).to receive(:root).and_return(bundled_app)
Bundler.reset_paths!

expect(Bundler).not_to receive(:mkdir_p)

Bundler.bin_path
end
end

describe "#mkdir_p" do
it "creates a folder at the given path" do
install_gemfile <<-G
Expand Down
8 changes: 8 additions & 0 deletions bundler/spec/bundler/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
expect(out).to eq("Hello, world")
end

it "does not execute a bundler-<task> binary that is only in the current directory" do
create_file(bundled_app("bundler-testtasks"), "#!/usr/bin/env ruby\nputs 'Hello, world'\n")

bundle "testtasks", raise_on_error: false

expect(err).to include('Could not find command "testtasks".')
end

describe "aliases" do
it "aliases e to exec" do
bundle "e --help"
Expand Down
24 changes: 24 additions & 0 deletions bundler/spec/bundler/fetcher/downloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@
end
end

context "when the redirect uri is on the same host but another port" do
let(:uri) { Gem::URI("https://username:password@www.uri-to-fetch.com/api/v2/endpoint") }

before { http_response["location"] = "https://www.uri-to-fetch.com:8443/api/v1/endpoint" }

it "should not set the user and password for the redirect uri" do
expect(subject).to receive(:fetch).with(uri, options, 0).and_call_original
expect(subject).to receive(:fetch).with(Gem::URI("https://www.uri-to-fetch.com:8443/api/v1/endpoint"), options, 1)
subject.fetch(uri, options, counter)
end
end

context "when the redirect uri is on the same host but another scheme" do
let(:uri) { Gem::URI("http://username:password@www.uri-to-fetch.com:8080/api/v2/endpoint") }

before { http_response["location"] = "https://www.uri-to-fetch.com:8080/api/v1/endpoint" }

it "should not set the user and password for the redirect uri" do
expect(subject).to receive(:fetch).with(uri, options, 0).and_call_original
expect(subject).to receive(:fetch).with(Gem::URI("https://www.uri-to-fetch.com:8080/api/v1/endpoint"), options, 1)
subject.fetch(uri, options, counter)
end
end

context "when the redirect uri downgrades https to http" do
let(:uri) { Gem::URI("https://username:password@www.uri-to-fetch.com/api/v2/endpoint") }

Expand Down
8 changes: 8 additions & 0 deletions bundler/spec/commands/help_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
expect(out).to eq("--help")
end

it "does not execute a bundler-<task> binary that is only in the current directory" do
create_file(bundled_app("bundler-testtasks"), "#!/usr/bin/env ruby\nputs ARGV.join(' ')\n")

bundle "help testtasks", raise_on_error: false

expect(err).to include('Could not find command "testtasks".')
end

it "is called when the --help flag is used after the command" do
with_fake_man do
bundle "install --help"
Expand Down
39 changes: 39 additions & 0 deletions bundler/spec/commands/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,45 @@
G
end

it "reports the effective platform when force_ruby_platform is set in the environment" do
gemfile <<-G
source "https://gem.repo1"

#{ruby_version_correct}

gem "foo"
G

bundle "platform", env: { "BUNDLE_FORCE_RUBY_PLATFORM" => "true" }
expect(out).to eq(<<-G.chomp)
Your platform is: #{Gem::Platform.local}
However, your effective platform is: ruby (because force_ruby_platform is set via BUNDLE_FORCE_RUBY_PLATFORM: true)

Your app has gems that work on these platforms:
* #{Gem::Platform::RUBY}

Your Gemfile specifies a Ruby version requirement:
* ruby #{Gem.ruby_version}

Your current platform satisfies the Ruby version requirement.
G
end

it "points at the config file when force_ruby_platform is set there" do
gemfile <<-G
source "https://gem.repo1"

#{ruby_version_correct}

gem "foo"
G

bundle "config set --local force_ruby_platform true"
bundle "platform"
expect(out).to include("However, your effective platform is: ruby " \
"(because force_ruby_platform is set for your local app (#{bundled_app(".bundle/config")}): true)")
end

it "returns all the output including the patchlevel" do
gemfile <<-G
source "https://gem.repo1"
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/realworld/fixtures/tapioca/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ DEPENDENCIES
tapioca

BUNDLED WITH
4.0.21
4.0.22
Loading
Loading