diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-26 20:43:33 -0700 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-03-26 20:43:33 -0700 |
commit | 9b8f47c7c8118c6ce6514f2e1073b2e50b37b117 (patch) | |
tree | 58f8d6f8490615cee951b39f3b296129cf4f608c /lib/chef/util | |
parent | eaa56e53be8d71665a5b9a828db54898b7b36fc8 (diff) | |
download | chef-9b8f47c7c8118c6ce6514f2e1073b2e50b37b117.tar.gz |
Fix bug where unset HOME would cause chef to crash
Issue #3153
When running chef with HOME unset (going to be a common case on
the nixs), Chef will crash when it uses the all_homes function.
Diffstat (limited to 'lib/chef/util')
-rw-r--r-- | lib/chef/util/path_helper.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/util/path_helper.rb b/lib/chef/util/path_helper.rb index 17c7175331..66c2e3f19f 100644 --- a/lib/chef/util/path_helper.rb +++ b/lib/chef/util/path_helper.rb @@ -196,7 +196,7 @@ class Chef paths << ENV['HOMESHARE'] + ENV['HOMEPATH'] if ENV['HOMESHARE'] && ENV['HOMEPATH'] paths << ENV['USERPROFILE'] end - paths << Dir.home + paths << Dir.home if ENV['HOME'] # Depending on what environment variables we're using, the slashes can go in any which way. # Just change them all to / to keep things consistent. @@ -204,11 +204,11 @@ class Chef # the particular brand of kool-aid you consume. This code assumes that \ and / are both # path separators on any system being used. paths = paths.map { |home_path| home_path.gsub(path_separator, ::File::SEPARATOR) if home_path } - + # Filter out duplicate paths and paths that don't exist. valid_paths = paths.select { |home_path| home_path && Dir.exists?(home_path) } valid_paths = valid_paths.uniq - + # Join all optional path elements at the end. # If a block is provided, invoke it - otherwise just return what we've got. joined_paths = valid_paths.map { |home_path| File.join(home_path, *args) } |