Skip to content

Commit

Permalink
[bundler/bundler] Fix bundle doctor command
Browse files Browse the repository at this point in the history
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.

rubygems/bundler@5531a18c1e
  • Loading branch information
deivid-rodriguez authored and hsbt committed Aug 18, 2019
1 parent a02dbce commit cc644c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/cli/doctor.rb
Expand Up @@ -100,7 +100,7 @@ def check_home_permissions
files_not_readable_or_writable = []
files_not_rw_and_owned_by_different_user = []
files_not_owned_by_current_user_but_still_rw = []
Find.find(Bundler.home.to_s).each do |f|
Find.find(Bundler.bundle_path.to_s).each do |f|
if !File.writable?(f) || !File.readable?(f)
if File.stat(f).uid != Process.uid
files_not_rw_and_owned_by_different_user << f
Expand Down
10 changes: 8 additions & 2 deletions spec/bundler/commands/doctor_spec.rb
Expand Up @@ -22,11 +22,17 @@
end
end

it "succeeds on a sane installation" do
bundle :doctor

expect(exitstatus).to eq(0)
end

context "when all files in home are readable/writable" do
before(:each) do
stat = double("stat")
unwritable_file = double("file")
allow(Find).to receive(:find).with(Bundler.home.to_s) { [unwritable_file] }
allow(Find).to receive(:find).with(Bundler.bundle_path.to_s) { [unwritable_file] }
allow(File).to receive(:stat).with(unwritable_file) { stat }
allow(stat).to receive(:uid) { Process.uid }
allow(File).to receive(:writable?).with(unwritable_file) { true }
Expand Down Expand Up @@ -66,7 +72,7 @@
before(:each) do
@stat = double("stat")
@unwritable_file = double("file")
allow(Find).to receive(:find).with(Bundler.home.to_s) { [@unwritable_file] }
allow(Find).to receive(:find).with(Bundler.bundle_path.to_s) { [@unwritable_file] }
allow(File).to receive(:stat).with(@unwritable_file) { @stat }
end

Expand Down

0 comments on commit cc644c7

Please sign in to comment.