jonathanmorley / asdf-bundler

Apache License 2.0
7 stars 4 forks source link

Binstubs do not work if bin/bundle exists #7

Open odinhb opened 2 years ago

odinhb commented 2 years ago

Bundler allows you to generate binstubs using $ bundle binstubs --all.

When trying to run the resulting binstubs I get this:

Activating bundler (~> 2.3) failed:
Could not find 'bundler' (2.3.5) required by your /home/odin/dev/fakturabank/Gemfile.lock.
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.3.5`
Checked in 'GEM_PATH=/home/odin/.gem/ruby/2.7.0:/home/odin/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0', execute `gem env` for more information

To install the version of bundler this project requires, run `gem install bundler -v '~> 2.3'`

My gemfile says:

BUNDLED WITH
   2.3.5
gem env output ``` RubyGems Environment: - RUBYGEMS VERSION: 3.1.6 - RUBY VERSION: 2.7.5 (2021-11-24 patchlevel 203) [x86_64-linux] - INSTALLATION DIRECTORY: /home/odin/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0 - USER INSTALLATION DIRECTORY: /home/odin/.gem/ruby/2.7.0 - RUBY EXECUTABLE: /home/odin/.asdf/installs/ruby/2.7.5/bin/ruby - GIT EXECUTABLE: /usr/bin/git - EXECUTABLE DIRECTORY: /home/odin/.asdf/installs/ruby/2.7.5/bin - SPEC CACHE DIRECTORY: /home/odin/.gem/specs - SYSTEM CONFIGURATION DIRECTORY: /home/odin/.asdf/installs/ruby/2.7.5/etc - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /home/odin/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0 - /home/odin/.gem/ruby/2.7.0 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - https://rubygems.org/ - SHELL PATH: - /home/odin/.asdf/installs/ruby/2.7.5/bin - /home/odin/.asdf/shims - /home/odin/.asdf/bin - /usr/src/linux-headers-5.14.0-16.4-liquorix-amd64/tools/power/x86/x86_energy_perf_policy - /usr/src/linux-headers-5.14.0-16.4-liquorix-amd64/tools/power/x86/turbostat - /usr/src/linux-headers-5.14.0-16.4-liquorix-amd64/tools/power/cpupower - /usr/src/linux-headers-5.14.0-16.4-liquorix-amd64/tools/perf - /usr/local/sbin - /usr/local/bin - /usr/sbin - /usr/bin - /sbin - /bin - /usr/games - /usr/local/games - /snap/bin ```

I am trying to use asdf-bundler similiar to #6 for pinning a version of bundler even though I'm also using asdf-ruby.

In my .bundle/config file I also have

BUNDLE_PATH: ".gem-bundle"

Which makes bundler install all the dependencies inside the .gem-bundle folder in the local project.

Interestingly, if I delete bin/bundle or comment out this code block from the binstub I'm trying to run:

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
  if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
    load(bundle_binstub)
  else
    abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
  end
end

Then it works just fine.

I'm not sure how to solve this except sticking to bundle exec for now. But I'd like to be able to use the binstubs as well. Maybe this has to be fixed in https://github.com/rubygems/rubygems ?