Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.
This repository was archived by the owner on May 3, 2024. It is now read-only.

Doesn't work with implicit/child gems #2

@indirect

Description

@indirect

I can't quite tell if this is intended to work or not, but it surprised me because Bundler binstubs work even with gems that aren't explicitly in the Gemfile:

bundle init
bundle add subbundle
bundle add guard-rubocop
mkdir bin
echo 'unless defined?(Subbundle)
  require "bundler"

  Bundler.locked_gems.specs.find { |spec| spec.name == "subbundle" }&.tap do |subbundle|
    Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
    gem "subbundle", subbundle.version
    require "subbundle"
  end
end' > bin/subbundle

echo '# Load the subbundle binstub first.
load File.expand_path("subbundle", __dir__)
# Setup the subbundle.
Subbundle.setup("rubocop")

# Execute the binary.
load Gem.bin_path("rubocop", "rubocop")' > bin/rubocop

ruby bin/rubocop
/Users/andre/.gem/ruby/3.1.2/gems/bundler-2.3.11/lib/bundler/rubygems_integration.rb:319:in `block in replace_bin_path': can't find executable rubocop for gem rubocop. rubocop is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
        from /Users/andre/.gem/ruby/3.1.2/gems/bundler-2.3.11/lib/bundler/rubygems_integration.rb:358:in `block in replace_bin_path'
        from bin/rubocop:7:in `<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions