Skip to content
Open
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: 4 additions & 0 deletions bundler/lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def self.default_command(meth = nil)
def help(cli = nil)
cli = self.class.all_aliases[cli] if self.class.all_aliases[cli]

if Bundler.settings[:plugins] && Bundler::Plugin.command?(cli) && !self.class.all_commands.key?(cli)
return Bundler::Plugin.exec_command(cli, ["--help"])
end

case cli
when "gemfile" then command = "gemfile"
when nil then command = "bundle"
Expand Down
34 changes: 34 additions & 0 deletions bundler/spec/plugins/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,40 @@ def exec(command, args)
expect(out).to eq("You gave me tacos, tofu, lasange")
end

it "passes help flag to plugin" do
update_repo2 do
build_plugin "helpful" do |s|
s.write "plugins.rb", <<-RUBY
module Helpful
class Command
Bundler::Plugin::API.command "greet", self

def exec(command, args)
if args.include?("--help") || args.include?("-h")
puts "Usage: bundle greet [NAME]"
else
puts "Hello"
end
end
end
end
RUBY
end
end

bundle "plugin install helpful --source https://gem.repo2"
expect(out).to include("Installed plugin helpful")

bundle "greet --help"
expect(out).to eq("Usage: bundle greet [NAME]")

bundle "greet -h"
expect(out).to eq("Usage: bundle greet [NAME]")

bundle "help greet"
expect(out).to eq("Usage: bundle greet [NAME]")
end
Comment on lines 80 to 88
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spec covers bundle greet --help and bundle greet -h, but the change in Bundler::CLI#help also affects bundle help greet (which is another common way to request help and previously triggered the crash path). Adding an assertion for bundle "help greet" would better lock in the intended behavior and prevent regressions specific to the help subcommand.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback


it "raises error on redeclaration of command" do
update_repo2 do
build_plugin "copycat" do |s|
Expand Down