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

Fix bundle doctor command #7309

Merged
1 commit merged into from
Aug 17, 2019
Merged

Fix bundle doctor command #7309

1 commit merged into from
Aug 17, 2019

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Aug 16, 2019

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

The problem was that bundle doctor crashes on very simple usages, like this:

$ bundle doctor
The Gemfile's dependencies are satisfied
--- ERROR REPORT TEMPLATE -------------------------------------------------------
# Error Report

## Questions

Please fill out answers to these questions, it'll help us figure out
why things are going wrong.

- **What did you do?**

  I ran the command `/home/deivid/.rbenv/versions/2.6.3/bin/bundle doctor`

- **What did you expect to happen?**

  I expected Bundler to...

- **What happened instead?**

  Instead, what happened was...

- **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?**

  I tried...

- **Have you read our issues document, https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md?**

  ...

## Backtrace

```
Errno::ENOENT: No such file or directory - /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0/bundler
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/2.6.0/find.rb:43:in `block in find'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/2.6.0/find.rb:43:in `collect!'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/2.6.0/find.rb:43:in `find'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli/doctor.rb:105:in `each'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli/doctor.rb:105:in `check_home_permissions'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli/doctor.rb:83:in `run'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli.rb:652:in `doctor'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli.rb:26:in `dispatch'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli.rb:17:in `start'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/exe/bundle:30:in `block in <top (required)>'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/exe/bundle:22:in `<top (required)>'
  /home/deivid/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
  /home/deivid/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'
```

## Environment

```
Bundler       2.1.0.pre.1
  Platforms   ruby, x86_64-linux
Ruby          2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
  Full Path   /home/deivid/.rbenv/versions/2.6.3/bin/ruby
  Config Dir  /home/deivid/.rbenv/versions/2.6.3/etc
RubyGems      3.1.0.pre1
  Gem Home    /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0
  Gem Path    /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0
  User Home   /home/deivid
  User Path   /home/deivid/.gem/ruby/2.6.0
  Bin Dir     /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0/bin
Tools         
  Git         2.22.1
  RVM         not installed
  rbenv       rbenv 1.1.2
  chruby      not installed
```

## Bundler Build Metadata

```
Built At          2019-08-15
Git SHA           91f91a1ad
Released Version  false
```

## Bundler settings

```
gem.test
  Set for the current user (/home/deivid/.bundle/config): "rspec"
gem.mit
  Set for the current user (/home/deivid/.bundle/config): true
gem.coc
  Set for the current user (/home/deivid/.bundle/config): true
default_cli_command
  Set for the current user (/home/deivid/.bundle/config): "install"
path_relative_to_cwd
  Set for the current user (/home/deivid/.bundle/config): true
path
  Set for your local app (/home/deivid/Code/playground/bundler/chcek/.bundle/config): ".bundle"
```

## Gemfile

### Gemfile

```ruby
source "https://rubygems.org"

gem "rake", "12.3.2"

gem "byebug", "~> 11.0"
```

### Gemfile.lock

```
GEM
  remote: https://rubygems.org/
  specs:
    byebug (11.0.1)
    rake (12.3.2)

PLATFORMS
  ruby

DEPENDENCIES
  byebug (~> 11.0)
  rake (= 12.3.2)

BUNDLED WITH
   2.1.0.pre.1
```

--- TEMPLATE END ----------------------------------------------------------------

Unfortunately, an unexpected error occurred, and Bundler cannot continue.

First, try this link to see if there are any existing issue reports for this error:
https://github.com/bundler/bundler/search?q=No+such+file+or+directory+-+%2Fhome%2Fdeivid%2FCode%2Fplayground%2Fbundler%2Fchcek%2F.bundle%2Fruby%2F2.6.0%2Fbundler&type=Issues

If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
https://github.com/bundler/bundler/issues/new

What was your diagnosis of the problem?

My diagnosis was that Bundler.home is not the folder this command should use, because that folder is in reality the "home" for git gems and bundler plugins, not the home for the whole bundle. So it sometimes doesn't exist and the command crashes.

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

My fix is to use the proper "home".

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

I chose this fix because it's better than rescuing the error. It was an unexpected error, so we should fix it.

Fixes #6820
Closes #6824.

Previously `bundle doctor` would fail on any bundle that does not
include git gems or plugins. This is because the previously used
`Bundler.home` does not exist unless the bundle includes git gems or
plugins. For example, with `bundle config set path .bundle`, it points
to which does not exist unless this kind of gems exist in the Gemfile.

The name `Bundler.home` is really unfortunate, it should probably be
have more descriptive name, and be private. But for now I just want to
make `bundle doctor` usable.
@deivid-rodriguez
Copy link
Member Author

Thank you @hsbt!

@bundlerbot r=hsbt

ghost pushed a commit that referenced this pull request Aug 17, 2019
7309: Fix `bundle doctor` command r=hsbt a=deivid-rodriguez

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

The problem was that `bundle doctor` crashes on very simple usages, like this:

````
$ bundle doctor
The Gemfile's dependencies are satisfied
--- ERROR REPORT TEMPLATE -------------------------------------------------------
# Error Report

## Questions

Please fill out answers to these questions, it'll help us figure out
why things are going wrong.

- **What did you do?**

  I ran the command `/home/deivid/.rbenv/versions/2.6.3/bin/bundle doctor`

- **What did you expect to happen?**

  I expected Bundler to...

- **What happened instead?**

  Instead, what happened was...

- **Have you tried any solutions posted on similar issues in our issue tracker, stack overflow, or google?**

  I tried...

- **Have you read our issues document, https://github.com/bundler/bundler/blob/master/doc/contributing/ISSUES.md?**

  ...

## Backtrace

```
Errno::ENOENT: No such file or directory - /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0/bundler
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/2.6.0/find.rb:43:in `block in find'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/2.6.0/find.rb:43:in `collect!'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/2.6.0/find.rb:43:in `find'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli/doctor.rb:105:in `each'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli/doctor.rb:105:in `check_home_permissions'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli/doctor.rb:83:in `run'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli.rb:652:in `doctor'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli.rb:26:in `dispatch'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/cli.rb:17:in `start'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/exe/bundle:30:in `block in <top (required)>'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
  /home/deivid/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bundler-2.1.0.pre.1/exe/bundle:22:in `<top (required)>'
  /home/deivid/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
  /home/deivid/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'
```

## Environment

```
Bundler       2.1.0.pre.1
  Platforms   ruby, x86_64-linux
Ruby          2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
  Full Path   /home/deivid/.rbenv/versions/2.6.3/bin/ruby
  Config Dir  /home/deivid/.rbenv/versions/2.6.3/etc
RubyGems      3.1.0.pre1
  Gem Home    /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0
  Gem Path    /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0
  User Home   /home/deivid
  User Path   /home/deivid/.gem/ruby/2.6.0
  Bin Dir     /home/deivid/Code/playground/bundler/chcek/.bundle/ruby/2.6.0/bin
Tools         
  Git         2.22.1
  RVM         not installed
  rbenv       rbenv 1.1.2
  chruby      not installed
```

## Bundler Build Metadata

```
Built At          2019-08-15
Git SHA           91f91a1
Released Version  false
```

## Bundler settings

```
gem.test
  Set for the current user (/home/deivid/.bundle/config): "rspec"
gem.mit
  Set for the current user (/home/deivid/.bundle/config): true
gem.coc
  Set for the current user (/home/deivid/.bundle/config): true
default_cli_command
  Set for the current user (/home/deivid/.bundle/config): "install"
path_relative_to_cwd
  Set for the current user (/home/deivid/.bundle/config): true
path
  Set for your local app (/home/deivid/Code/playground/bundler/chcek/.bundle/config): ".bundle"
```

## Gemfile

### Gemfile

```ruby
source "https://rubygems.org"

gem "rake", "12.3.2"

gem "byebug", "~> 11.0"
```

### Gemfile.lock

```
GEM
  remote: https://rubygems.org/
  specs:
    byebug (11.0.1)
    rake (12.3.2)

PLATFORMS
  ruby

DEPENDENCIES
  byebug (~> 11.0)
  rake (= 12.3.2)

BUNDLED WITH
   2.1.0.pre.1
```

--- TEMPLATE END ----------------------------------------------------------------

Unfortunately, an unexpected error occurred, and Bundler cannot continue.

First, try this link to see if there are any existing issue reports for this error:
https://github.com/bundler/bundler/search?q=No+such+file+or+directory+-+%2Fhome%2Fdeivid%2FCode%2Fplayground%2Fbundler%2Fchcek%2F.bundle%2Fruby%2F2.6.0%2Fbundler&type=Issues

If there aren't any reports for this error yet, please create copy and paste the report template above into a new issue. Don't forget to anonymize any private data! The new issue form is located at:
https://github.com/bundler/bundler/issues/new
````

### What was your diagnosis of the problem?

My diagnosis was that `Bundler.home` is not the folder this command should use, because that folder is in reality the "home" for git gems and bundler plugins, not the home for the whole bundle. So it sometimes doesn't exist and the command crashes.

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

My fix is to use the proper "home".

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

I chose this fix because it's better than rescuing the error. It was an unexpected error, so we should fix it.

Fixes #6820 
Closes #6824.


Co-authored-by: David Rodríguez <[email protected]>
@ghost
Copy link

ghost commented Aug 17, 2019

Build succeeded

@ghost ghost merged commit 5531a18 into master Aug 17, 2019
@ghost ghost deleted the fix_bundle_doctor branch August 17, 2019 23:30
@pyrogenic
Copy link

Just wanted to thank you for this fix — got rid of a spurious error for me!

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.

General Problem to run bundle doctor
3 participants