Skip to content

Commit

Permalink
Fix chocolatey.exe detection
Browse files Browse the repository at this point in the history
Summary:
This diff is a part of bigger effort to migrate from engenv chef to prod chef solo.

In the lab environment, there is no Chocolatey present on the machine during the chef bootstrap, and it's important to properly detect the `chocolatey.exe`.

In the recent chef versions (17.4.38) the behavior of the `which()` function changed, and now it's returning `false` instead of `nil`.
If you look at D36651569, you can see that the return value of `which()` is changing.
To be on the safe side, I am adding the test that looks for **both** `nil` and `false`

Differential Revision: D56729989

fbshipit-source-id: 35f071a9b2ab131dfa5ac71cff1bd7939d921864
  • Loading branch information
Jan Korycan authored and facebook-github-bot committed May 3, 2024
1 parent 79bb1a3 commit 110297b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cookbooks/fb_choco/libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_choco_bin
# choco.exe in $env:PATH it returns 'nil'
# In this situtation lets also check the most likely location.
which_path = which(file_name)
return which_path unless which_path.nil?
return which_path unless which_path.nil? || (which_path == false)

expected_paths = [
"C:\\ProgramData\\Chocolatey\\bin\\#{file_name}",
Expand Down

0 comments on commit 110297b

Please sign in to comment.