Open brandonfriess-stripe opened 12 months ago
Possibly related to changes in https://github.com/chef/chef/pull/13669 ?
I'm puzzled how false
is being surfaced here when I clearly have the right types for the resource.
@brandonfriess-stripe are you still seeing this on newer client versions like 18.3.x, 18.4.x? I ran into a similar TypeError which I believe is caused by the Chef::Mixin::HomebrewUser.find_homebrew_username
. I can see why running under the launchctl/root context might also make a repro occur here.
@jazaval I ended up working around it by adding the brew binary path, user, and home dir to the env.
For whatever reason, Chef doesn't expose a property to set the homebrew user or binary path. However...
Deep in the homebrew_update resource they are calling the execute resource and I'm hi-jacking that process to set the ENV to the right things so that this resource will fire correctly under launchd.
Ex:
action :manage do
if node['cpe_homebrew']['auto-update']
# Set PATH for Homebrew auto-update so it works in launchd
ENV['PATH'] = if node.arm64?
"/opt/homebrew/bin:/opt/homebrew/sbin:#{ENV['PATH']}"
else
"/usr/local/bin:/usr/local/sbin:#{ENV['PATH']}"
end
ENV['HOME'] = ::Dir.home(node['cpe_homebrew']['user'])
ENV['USER'] = node['cpe_homebrew']['user']
homebrew_update 'macOS' do
frequency 86_400
action :periodic
ignore_failure true
retries 1
end
end
end
For your case, I wonder if you set the owner
property to the primary user, it would probably work for you.
Description
I've been seeing an increase of failures in the
homebrew_update
resource when Chef is being ran under launchd on macOS.The error is this:
Chef Version
18.3.0
Platform Version
macOS
Replication Case
Add the
homebrew_update
resource to a recipe and run Chef job via launchd.(i.e.
sudo launchctl unload /Library/LaunchDaemon/com.chef.chef-client.plist && sudo launchctl load /Library/LaunchDaemon/com.chef.chef-client.plist
)Client Output
Stacktrace