jumanjihouse/pre-commit-hooks

Markdownlint fails with "Could not find 'bundler'" on MacOS - install specific bundler version

michael-paddle opened this issue · 1 comments

I have a pre-commit coinfiguration clause like this.

- repo: https://github.com/jumanjihouse/pre-commit-hooks
  rev: 'master'  # Use the sha / tag you want to point at
  hooks:
  - id: markdownlint
    args:
    - -r MD046=consistent

when running pre-commit it failed like so:

/usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'bundler' (>= 1.2.0, < 3) among 41 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/michael-mbp/.gem/ruby/2.6.0:/usr/local/lib/ruby/gems/2.6.0:/usr/local/Cellar/ruby/2.6.2/lib/ruby/gems/2.6.0:/Users/michael-mbp/.cache/pre-commit/repo1_2m2ecl/rbenv-default/gems', execute `gem env` for more information
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1449:in `block in activate_dependencies'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `each'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `activate_dependencies'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1420:in `activate'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1452:in `block in activate_dependencies'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `each'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `activate_dependencies'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems/specification.rb:1420:in `activate'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems.rb:304:in `block in activate_bin_path'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems.rb:303:in `synchronize'
	from /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
	from /Users/michael-mbp/.cache/pre-commit/repo1_2m2ecl/rbenv-default/gems/bin/run-mdl:23:in `<main>'

This appears to be related to this issue with bundler - https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html

I have ruby installed from homebrew. Running

gem install bundler -v 2.0.1

solved this problem for me. Leaving this record for posterity in case someone else hits the same issue. There might be an automated fix that is possible for pre-commit but I think it would be too complex so I'm closing this ticket. Please reopen if you have some reason to think there's a reasonable proper way to fix.