diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index e784285e..88134dc1 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -81,7 +81,7 @@ class Pry expanded = Pathname.new(File.expand_path(file)).realpath.to_s # For rbx 1.9 mode [see rubinius issue #2165] File.exist?(expanded) ? expanded : nil - rescue Errno::ENOENT + rescue Errno::ENOENT, Errno::EACCES nil end diff --git a/spec/pryrc_spec.rb b/spec/pryrc_spec.rb index 3315527e..6d802c8d 100644 --- a/spec/pryrc_spec.rb +++ b/spec/pryrc_spec.rb @@ -37,6 +37,17 @@ describe Pry do end end + it "should not load the pryrc if pryrc's directory permissions do not allow this" do + Dir.mktmpdir do |dir| + FileUtils.chmod 0, dir + Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc') + puts Pry::LOCAL_RC_FILE + Pry.config.should_load_rc = true + expect { Pry.start(self, :input => StringIO.new("exit-all\n"), :output => StringIO.new) }.to_not raise_error + FileUtils.chmod 777, dir + end + end + it "should not load the pryrc if it cannot expand ENV[HOME]" do old_home = ENV['HOME'] ENV['HOME'] = nil