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

Commit

Permalink
Add check of Dir.home's permission
Browse files Browse the repository at this point in the history
  • Loading branch information
allenzhao committed Aug 16, 2016
1 parent 138b8c1 commit e85acda
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def self.start(*)
raise e
ensure
Bundler::SharedHelpers.print_major_deprecations!
Bundler::SharedHelpers.check_home_dir_permissions
end

def self.dispatch(*)
Expand Down
4 changes: 4 additions & 0 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def print_major_deprecations!
major_deprecation("Bundler will only support rubygems >= 2.0, you are running #{Bundler.rubygems.version}")
end

def check_home_dir_permissions
raise PathError, "There was an error while trying to use your home path #{Dir.home}" unless File.writable?(Dir.home)
end

private

def find_gemfile
Expand Down
7 changes: 7 additions & 0 deletions spec/bundler/shared_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,4 +412,11 @@ module TargetNamespace
end
end
end

describe "#check_home_dir_permissions" do
it "raises a PathError" do
allow(File).to receive(:writable?).with(Dir.home).and_return(false)
expect { subject.check_home_dir_permissions }.to raise_error(Bundler::PathError, /There was an error while trying to use your home path/)
end
end
end

0 comments on commit e85acda

Please sign in to comment.