diff options
author | unknown <cdoherty@chef.io> | 2016-02-24 11:42:06 -0800 |
---|---|---|
committer | unknown <cdoherty@chef.io> | 2016-02-24 14:02:47 -0800 |
commit | 8bfde4491d53696d2242c4a0d52ccf6cf082f16c (patch) | |
tree | 765fa9d0805f0c287091c726247cad053e0793b3 /lib | |
parent | 4ed2fc9307f57911e376ec946faf05353f301106 (diff) | |
download | chef-8bfde4491d53696d2242c4a0d52ccf6cf082f16c.tar.gz |
Change the Chocolatey check to look for choco.exe in #choco.exe.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/package/chocolatey.rb | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb index 6804e99a13..1d660f2cfd 100644 --- a/lib/chef/provider/package/chocolatey.rb +++ b/lib/chef/provider/package/chocolatey.rb @@ -52,12 +52,7 @@ EOS def define_resource_requirements super - requirements.assert(:all_actions) do |a| - # GetEnvironmentVariable returns "" on failure. - a.assertion { !choco_install_path.to_s.empty? } - a.failure_message(Chef::Exceptions::MissingLibrary, CHOCO_MISSING_MSG) - a.whyrun("Assuming Chocolatey is installed") - end + # The check that Chocolatey is installed is in #choco_exe. # Chocolatey source attribute points to an alternate feed # and not a package specific alternate source like other providers @@ -152,11 +147,15 @@ EOS # # @return [String] full path of choco.exe def choco_exe - @choco_exe ||= ::File.join( - choco_install_path, - "bin", - "choco.exe" - ) + @choco_exe ||= + # if this check is in #define_resource_requirements, it won't get + # run before choco.exe gets called from #load_current_resource. + exe_path = ::File.join(choco_install_path, "bin", "choco.exe") + if !::File.exists?(exe_path.to_s) + raise Chef::Exceptions::MissingLibrary, CHOCO_MISSING_MSG + else + exe_path + end end # lets us mock out an incorrect value for testing. |