summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2022-01-13 17:45:10 -0800
committerTim Smith <tsmith84@gmail.com>2022-01-13 17:45:10 -0800
commitf3e1ecf2b32e045aee27a0fc30fdfcd90851a43d (patch)
tree168019d1b86b0859567276d184ab993d6b7263c7
parent06185b342784a40891be8850fcad97221e290f70 (diff)
downloadchef-f3e1ecf2b32e045aee27a0fc30fdfcd90851a43d.tar.gz
user: handle nil home dirs on macOS
Don't fail with a NoMethodError error if home is not defined. We're seeing this failure in our specs right now. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/user/mac.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/provider/user/mac.rb b/lib/chef/provider/user/mac.rb
index 8e5b3d1cf3..838dca7886 100644
--- a/lib/chef/provider/user/mac.rb
+++ b/lib/chef/provider/user/mac.rb
@@ -48,7 +48,7 @@ class Chef
if user_plist
current_resource.uid(user_plist[:uid][0])
current_resource.gid(user_plist[:gid][0])
- current_resource.home(user_plist[:home][0])
+ current_resource.home(user_plist[:home]&.first) # use &.first since home can be nil
current_resource.shell(user_plist[:shell]&.first) # use &.first since shell can be nil
current_resource.comment(user_plist[:comment][0])