diff options
author | Claire McQuin <mcquin@users.noreply.github.com> | 2014-06-18 15:15:41 -0700 |
---|---|---|
committer | Claire McQuin <mcquin@users.noreply.github.com> | 2014-06-18 15:15:41 -0700 |
commit | c26340adc6f817624fdb68033f6ada261f278881 (patch) | |
tree | 6ec2f5825d8834663d32287048aa891720ade293 | |
parent | ef303ea54815117b95ff4026e2dc4bdafbf13511 (diff) | |
parent | 655e5511f6c4e77fc4d74249c5100da8f3eacf0b (diff) | |
download | chef-c26340adc6f817624fdb68033f6ada261f278881.tar.gz |
Merge pull request #1494 from brettcave/CHEF-5365_master
CHEF-5365 - chef local crashes if home directory is not set
-rw-r--r-- | lib/chef/config.rb | 4 | ||||
-rw-r--r-- | spec/unit/config_spec.rb | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/config.rb b/lib/chef/config.rb index a908fb83d4..0ac82cc5ac 100644 --- a/lib/chef/config.rb +++ b/lib/chef/config.rb @@ -552,8 +552,8 @@ class Chef windows_home_path = env['SYSTEMDRIVE'] + env['HOMEPATH'] if env['SYSTEMDRIVE'] && env['HOMEPATH'] end - # returns a platform specific path to the user home dir - default( :user_home ) { env['HOME'] || windows_home_path || env['USERPROFILE'] } + # returns a platform specific path to the user home dir if set, otherwise default to current directory. + default( :user_home ) { env['HOME'] || windows_home_path || env['USERPROFILE'] || Dir.pwd } # Enable file permission fixup for selinux. Fixup will be done # only if selinux is enabled in the system. diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index c467d7d553..37527c04c4 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -341,6 +341,11 @@ describe Chef::Config do Chef::Config.stub(:env).and_return({ 'USERPROFILE' => "/users/kitten" }) Chef::Config[:user_home].should == "/users/kitten" end + + it "falls back to the current working directory when HOME and USERPROFILE is not set" do + Chef::Config.stub(:env).and_return({}) + Chef::Config[:user_home].should == Dir.pwd + end end describe "Chef::Config[:encrypted_data_bag_secret]" do |