Skip to content
This repository has been archived by the owner. It is now read-only.

Fix bundle exec rake install failing #7474

Merged
5 commits merged into from Dec 12, 2019
Merged

Fix bundle exec rake install failing #7474

5 commits merged into from Dec 12, 2019

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Dec 9, 2019

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

The problem was that I noticed bundle exec rake install was failing on my gem using the latest prerelease of bundler.

What was your diagnosis of the problem?

My diagnosis was that bundler silences output of rubygems by default, and in a bundle exec context, bundler/setup is always required by subprocesses. So, the rake install task is silencing rubygems, but it requires it to not be silent:

https://github.com/bundler/bundler/blob/bada03dd6d4d15828fb5b2cf7f744948e88a69a3/lib/bundler/gem_helper.rb#L91-L92

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

My fix is to wrap the execution of the rubygems subprocess with Bundler.with_original_env so that the gem command runs without bundler involved.

Like it is named in the other analogous methods.
And use it consistently.
These gem task checks for a specific string in the gem subcommand
output. However, if we are inside a bundled environment (`bundle exec
rake install` instead of `rake install`), the ruby process will require
`bundler/setup` first thing, and initialize a silent UI for rubygems. As
a result, the output string will be always empty and the condition for
success will always fail. So, even if installation succeeded, user will
always be notified of a failure like:

```
foo 1.0 built to pkg/foo-1.0.gem.
rake aborted!
Couldn't install gem, run `gem install /home/deivid/Code/bundler/tmp/1/bundled_app/pkg/foo-1.0.gem' for more detailed output
...
```

So, don't check for a specific string in the output and only rely on the
exit status.
This is leftover code that should've been removed on a previous PR.
@deivid-rodriguez
Copy link
Member Author

deivid-rodriguez commented Dec 12, 2019

@bundlerbot merge

ghost pushed a commit that referenced this issue Dec 12, 2019
7474: Fix `bundle exec rake install` failing r=deivid-rodriguez a=deivid-rodriguez

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

The problem was that I noticed `bundle exec rake install` was failing on my gem using the latest prerelease of bundler.

### What was your diagnosis of the problem?

My diagnosis was that `bundler` silences output of rubygems by default, and in a `bundle exec` context, `bundler/setup` is always required by subprocesses. So, the `rake install` task is silencing rubygems, but it requires it to not be silent:

https://github.com/bundler/bundler/blob/bada03dd6d4d15828fb5b2cf7f744948e88a69a3/lib/bundler/gem_helper.rb#L91-L92

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

My fix is to wrap the execution of the rubygems subprocess with `Bundler.with_original_env` so that the `gem` command runs without `bundler` involved.


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@ghost
Copy link

ghost commented Dec 12, 2019

Build succeeded

@ghost ghost merged commit aa4488a into master Dec 12, 2019
3 checks passed
@ghost ghost deleted the fix_gem_tasks branch Dec 12, 2019
@deivid-rodriguez deivid-rodriguez modified the milestones: 2.1.0.rc, 2.1.0 Dec 13, 2019
deivid-rodriguez pushed a commit that referenced this issue Dec 13, 2019
7474: Fix `bundle exec rake install` failing r=deivid-rodriguez a=deivid-rodriguez

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

The problem was that I noticed `bundle exec rake install` was failing on my gem using the latest prerelease of bundler.

### What was your diagnosis of the problem?

My diagnosis was that `bundler` silences output of rubygems by default, and in a `bundle exec` context, `bundler/setup` is always required by subprocesses. So, the `rake install` task is silencing rubygems, but it requires it to not be silent:

https://github.com/bundler/bundler/blob/bada03dd6d4d15828fb5b2cf7f744948e88a69a3/lib/bundler/gem_helper.rb#L91-L92

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

My fix is to wrap the execution of the rubygems subprocess with `Bundler.with_original_env` so that the `gem` command runs without `bundler` involved.

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
(cherry picked from commit f44ebf0)
This pull request was closed.
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.

None yet

1 participant