-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
Describe the problem as clearly as you can
I am working on a bundler plugin and trying to let it support bundle test -h or bundle test --help. However, anytime I run that, I get the following error:
$ bundle test -h
You called test with args: ["-h"]
Usage:
--- ERROR REPORT TEMPLATE -------------------------------------------------------
NoMethodError: undefined method 'formatted_usage' for nil
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor.rb:547:in 'Bundler::Thor.banner'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor.rb:264:in 'Bundler::Thor.command_help'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor.rb:668:in 'Bundler::Thor#help'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli.rb:141:in 'Bundler::CLI#help'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/cli.rb:29:in 'Bundler::CLI.start'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle:28:in 'block in <top (required)>'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/lib/bundler/friendly_errors.rb:117:in 'Bundler.with_friendly_errors'
/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.3/exe/bundle:20:in '<top (required)>'
/Users/daniel/.rbenv/versions/3.4.1/bin/bundle:25:in 'Kernel#load'
/Users/daniel/.rbenv/versions/3.4.1/bin/bundle:25:in '<main>'This happens even if the command's exec method is completely empty. It seems to be triggering something in Bundler::Thor prior to activating the plugin. If it matters, I have thor installed for my plugin via the gemspec, but it happens without it as well.
Did you try upgrading rubygems & bundler?
Yes:
$ gem -v
3.6.2
$ bundler -v
Bundler version 2.6.3Post steps to reproduce the problem
- Using ruby 3.4.1 via rbenv
- Create a new bundler plugin gem project called
bundler-test - Add the following to
Gemfile:
# frozen_string_literal: true
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
source 'https://rubygems.org'
gemspec
plugin 'bundler-test', path: '.'- Add
plugins.rbto set up the command:
require 'bundler'
require 'bundler/plugin'
class TestCommand
Bundler::Plugin::API.command('test', self)
# The exec method will be called with the `command_name` and the `args`.
# This is where you should handle all logic and functionality
def exec(command_name, args)
puts "You called " + command_name + " with args: " + args.inspect
end
end- Run
bundle install - Run
bundle test -horbundle test --helpand observe it crashes.
Which command did you run?
bundle test -h # or --help
What were you expecting to happen?
Not crash, allow my plugin to handle -h/--help.
What actually happened?
Bundler crashes, output listed above.
If not included with the output of your command, run bundle env and paste the output below
Environment
Bundler 2.6.3
Platforms ruby, arm64-darwin-24
Ruby 3.4.1p0 (2024-12-25 revision 48d4efcb85000e1ebae42004e963b5d0cedddcf2) [arm64-darwin-24]
Full Path /Users/daniel/.rbenv/versions/3.4.1/bin/ruby
Config Dir /Users/daniel/.rbenv/versions/3.4.1/etc
RubyGems 3.6.2
Gem Home /Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0
Gem Path /Users/daniel/.local/share/gem/ruby/3.4.0:/Users/daniel/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0
User Home /Users/daniel
User Path /Users/daniel/.local/share/gem/ruby/3.4.0
Bin Dir /Users/daniel/.rbenv/versions/3.4.1/bin
Tools
Git 2.42.1
RVM not installed
rbenv rbenv 1.3.0
chruby not installed
Bundler Build Metadata
Built At 2025-01-16
Git SHA 3c7c4ff2d8f
Released Version true
Gemfile
Gemfile
# frozen_string_literal: true
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
source 'https://rubygems.org'
gemspec
plugin 'bundler-test', path: '.'Gemfile.lock
PATH
remote: .
specs:
bundler-test (1.0.0)
thor (>= 1, < 2)
GEM
remote: https://rubygems.org/
specs:
thor (1.3.2)
PLATFORMS
arm64-darwin-24
ruby
DEPENDENCIES
bundler-test!
BUNDLED WITH
2.6.3
Gemspecs
bundler-test.gemspec
# frozen_string_literal: true
Gem::Specification.new do |spec|
spec.name = 'bundler-test'
spec.version = '1.0.0'
spec.required_ruby_version = '>= 2.7'
spec.authors = ['John Doe']
spec.summary = 'bundle plugin'
spec.metadata = {
'rubygems_mfa_required' => 'true'
}
spec.require_paths = ['lib']
spec.add_dependency 'thor', '>= 1', '< 2'
endReactions are currently unavailable