I have a simple Gemfile:
source 'https://rubygems.org'
gem 'librarian-puppet'
gem 'onceover'
When I install this using bundle (through rbenv shim: bundle install --path=vendor/bundle) then binstubs are installed in vendor/bundle/ruby/2.7.0/bin. But I can't execute them directly, for all I get the same result:
$ vendor/bundle/ruby/2.7.0/bin/onceover
Traceback (most recent call last):
2: from vendor/bundle/ruby/2.7.0/bin/onceover:23:in `<main>'
1: from /opt/puppetlabs/pdk/private/ruby/2.7.3/lib/ruby/site_ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/opt/puppetlabs/pdk/private/ruby/2.7.3/lib/ruby/site_ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem onceover (>= 0.a) with executable onceover (Gem::GemNotFoundException)
However, if I execute these binstubs using (rbenv shimmed) bundle exec then it works:
$ bundle exec onceover --help
...
So this is fine – although I'm not sure if it's expected, I'm a Ruby newbie.
But what confuses me is that one of the binstubs is bundle itself. Which would seems silly, since that only way to run it is bundle exec bundle which does work:
$ bundle exec bundle --version
Bundler version 2.1.4
However. This causes problems for me in IntelliJ IDEA, which when executing using bundle finds the binstubbed version and uses that. If I rm vendor/bundle/ruby/2.7.0/bin/bundle then it falls back to the rbenv shimmed version and is fine.
Finally, my question. Assuming this isn't wrong from the start, why does bundle install a binstub of itself? I have found other vendor directories where this did not seem to happen but I can't figure out the mechanism that causes the difference.