Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Setup custom Gemfile path before loading bundler for binstubs #6201

Merged

Conversation

pftg
Copy link
Contributor

@pftg pftg commented Dec 2, 2017

What was the end-user problem that led to this PR?

While you have several gemfiles: Gemfile and Gemfile.tools.
and generates binstubs for gems from second gemfile: BUNDLE_GEMFILE=Gemfile.tools bundle binstubs rubocop
when you invoke those bin bin/rubocop
then you see error like:

/usr/local/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:458: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 /usr/local/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:489:in `block in replace_bin_path'
	from bin/rubocop:21:in `<main>'

What was your diagnosis of the problem?

When you have generated bin/bundler by rails or by bundler it has setup of BUNDLE_GEMFILE by default as Gemfile or by gemfile which has been setup on bundle binstub bundler.

So your binstub for rubocop could not change it.

What is your fix for the problem, implemented in this PR?

I propose to useBUNDLE_GEMFILE from gem's binstub over bundler's binstub version

Why did you choose this fix out of the possible options?

This was default behavior before #5878 introduced. Just added some fix to related PR.

@ghost
Copy link

ghost commented Dec 2, 2017

Thanks for opening a pull request and helping make Bundler better! Someone from the Bundler team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use Travis CI to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of Travis CI in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #bundler channel on Slack.

For more information about contributing to the Bundler project feel free to review our CONTRIBUTING guide

@segiddins
Copy link
Member

Can you look into adding a test for this fix? Thanks!

@pftg
Copy link
Contributor Author

pftg commented Dec 2, 2017

yep, I'm in progress on this

@pftg pftg force-pushed the binstub-use-gemfile-from-env branch from f38ee7a to 2b1190a Compare December 2, 2017 20:22
@pftg pftg force-pushed the binstub-use-gemfile-from-env branch from 4f1bf2f to 0f62f28 Compare December 2, 2017 21:26
@pftg
Copy link
Contributor Author

pftg commented Dec 2, 2017

@segiddins added! you could check!

@indirect
Copy link
Member

indirect commented Dec 5, 2017

Thanks for this change! I believe this is the intended behavior :)

@segiddins
Copy link
Member

@indirect r? In that case?

@indirect
Copy link
Member

indirect commented Dec 5, 2017

@bundlerbot r+

@bundlerbot
Copy link
Collaborator

📌 Commit 0f62f28 has been approved by indirect

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 0f62f28 with merge 030a9c5...

bundlerbot added a commit that referenced this pull request Dec 5, 2017
…irect

Setup custom Gemfile path before loading bundler for binstubs

### What was the end-user problem that led to this PR?

While you have several gemfiles: `Gemfile` and `Gemfile.tools`.
and generates binstubs for gems from second gemfile: `BUNDLE_GEMFILE=Gemfile.tools bundle binstubs rubocop`
when you invoke those bin `bin/rubocop`
then you see error like:

```bash
/usr/local/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:458: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 /usr/local/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:489:in `block in replace_bin_path'
	from bin/rubocop:21:in `<main>'
```

### What was your diagnosis of the problem?

When you have generated `bin/bundler` by rails or by `bundler` it has setup of `BUNDLE_GEMFILE` by default as `Gemfile` or by gemfile which has been setup on `bundle binstub bundler`.

So your binstub for rubocop could not change it.

### What is your fix for the problem, implemented in this PR?

I propose to use`BUNDLE_GEMFILE` from gem's binstub over bundler's binstub version

### Why did you choose this fix out of the possible options?

This was default behavior before #5878 introduced. Just added some fix to related PR.
@bundlerbot
Copy link
Collaborator

☀️ Test successful - status-travis
Approved by: indirect
Pushing 030a9c5 to master...

@bundlerbot bundlerbot merged commit 0f62f28 into rubygems:master Dec 5, 2017
@pftg pftg deleted the binstub-use-gemfile-from-env branch December 5, 2017 07:31
@hsbt hsbt added this to the 1.16.1 milestone Dec 11, 2017
hsbt pushed a commit to hsbt/bundler that referenced this pull request Dec 11, 2017
…v, r=indirect

Setup custom Gemfile path before loading bundler for binstubs

### What was the end-user problem that led to this PR?

While you have several gemfiles: `Gemfile` and `Gemfile.tools`.
and generates binstubs for gems from second gemfile: `BUNDLE_GEMFILE=Gemfile.tools bundle binstubs rubocop`
when you invoke those bin `bin/rubocop`
then you see error like:

```bash
/usr/local/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:458: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 /usr/local/opt/rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/lib/bundler/rubygems_integration.rb:489:in `block in replace_bin_path'
	from bin/rubocop:21:in `<main>'
```

### What was your diagnosis of the problem?

When you have generated `bin/bundler` by rails or by `bundler` it has setup of `BUNDLE_GEMFILE` by default as `Gemfile` or by gemfile which has been setup on `bundle binstub bundler`.

So your binstub for rubocop could not change it.

### What is your fix for the problem, implemented in this PR?

I propose to use`BUNDLE_GEMFILE` from gem's binstub over bundler's binstub version

### Why did you choose this fix out of the possible options?

This was default behavior before rubygems#5878 introduced. Just added some fix to related PR.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants