From f813f54e42fa6d2c8ed42a0fa03fdd31e18b2292 Mon Sep 17 00:00:00 2001 From: Ryan Patterson Date: Tue, 8 Nov 2016 10:20:53 -0800 Subject: [PATCH] Enable support for macOS 10.12 Sierra --- lib/knife-solo/bootstraps/darwin.rb | 13 ++++++++++++- lib/knife-solo/resources/solo.rb.erb | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/knife-solo/bootstraps/darwin.rb b/lib/knife-solo/bootstraps/darwin.rb index 5d8170d4..c80cc392 100644 --- a/lib/knife-solo/bootstraps/darwin.rb +++ b/lib/knife-solo/bootstraps/darwin.rb @@ -7,11 +7,22 @@ def issue def distro case issue - when %r{10.(?:[6-9]|10)} + when %r{10.(?:[6-9]|1[0-2])} {:type => 'omnibus'} else raise "OS X version #{issue} not supported" end end + + def bootstrap! + super + if issue.split('.')[1].to_i >= 11 + # El Capitan and beyond do not have /usr/local/bin in the default paths, + # which is where chef gets installed. + path = "/usr/local/bin" + path_command = "[[ $PATH == *#{path}* ]] || echo 'export PATH=#{path}:$PATH' >> ~/.bashrc" + run_command(path_command) + end + end end end diff --git a/lib/knife-solo/resources/solo.rb.erb b/lib/knife-solo/resources/solo.rb.erb index 7b85df17..5beada85 100644 --- a/lib/knife-solo/resources/solo.rb.erb +++ b/lib/knife-solo/resources/solo.rb.erb @@ -19,3 +19,7 @@ cookbook_path << File.join(base, 'cookbooks-<%= i+1 %>') # <%= path %> <% proxy_settings.each_pair do |k, v| -%> <%= k %> "<%= v %>" <% end -%> + +# If the TMPDIR is not world-readable, set it to a location that is. This is +# necessary so that `script` resources can complete as non-root users on macOS. +ENV['TMPDIR'] = "/tmp"