From dd32ed1c3ca80d0d2a91cd89d123e5db74da913b Mon Sep 17 00:00:00 2001 From: Sachin Date: Fri, 19 Dec 2025 00:42:55 +0530 Subject: [PATCH 1/3] Fix chef exec and env command not working in Windows Signed-off-by: Sachin --- lib/chef-cli/helpers.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/chef-cli/helpers.rb b/lib/chef-cli/helpers.rb index c3133c67..926a3eb0 100644 --- a/lib/chef-cli/helpers.rb +++ b/lib/chef-cli/helpers.rb @@ -210,7 +210,8 @@ def omnibus_env end def get_pkg_prefix(pkg_name) - path = `hab pkg path #{pkg_name} 2>/dev/null`.strip + stderr_redirect = Chef::Platform.windows? ? "2>NUL" : "2>/dev/null" + path = `hab pkg path #{pkg_name} #{stderr_redirect}`.strip path if !path.empty? && Dir.exist?(path) # Return path only if it exists end @@ -265,7 +266,8 @@ def macos? # @api private # def hab_pkg_installed?(pkg_name) - `hab pkg list #{pkg_name} 2>/dev/null`.include?(pkg_name) rescue false + stderr_redirect = Chef::Platform.windows? ? "2>NUL" : "2>/dev/null" + `hab pkg list #{pkg_name} #{stderr_redirect}`.include?(pkg_name) rescue false end end end From fcdfa885b65583044ce5beac8bf29496cb74060f Mon Sep 17 00:00:00 2001 From: Sachin Date: Mon, 22 Dec 2025 18:58:56 +0530 Subject: [PATCH 2/3] add force_ruby_platform to use via bundle install Signed-off-by: Sachin --- habitat/plan.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index bc4650e2..0259675a 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -43,6 +43,7 @@ function Invoke-Build { bundle config --local jobs 4 bundle config --local retry 5 bundle config --local silence_root_warning 1 + bundle config set --local force_ruby_platform false Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies" bundle install @@ -67,7 +68,7 @@ function Invoke-Install { Push-Location $pkg_prefix bundle config --local gemfile $project_root/Gemfile Write-BuildLine "** generating binstubs for chef-cli with precise version pins" - Write-BuildLine "** generating binstubs for chef-cli with precise version pins $project_root $pkg_prefix/bin " + Write-BuildLine "** generating binstubs for chef-cli with precise version pins $project_root $pkg_prefix/bin " Invoke-Expression -Command "appbundler.bat $project_root $pkg_prefix/bin chef-cli" If ($lastexitcode -ne 0) { Exit $lastexitcode } Write-BuildLine " ** Running the chef-cli project's 'rake install' to install the path-based gems so they look like any other installed gem." From 8c2bf294e659b13a0b7288e2a31b2069d128987b Mon Sep 17 00:00:00 2001 From: Sachin Date: Tue, 23 Dec 2025 10:51:29 +0530 Subject: [PATCH 3/3] Revert "add force_ruby_platform to use via bundle install" This reverts commit fcdfa885b65583044ce5beac8bf29496cb74060f. --- habitat/plan.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/habitat/plan.ps1 b/habitat/plan.ps1 index 0259675a..bc4650e2 100644 --- a/habitat/plan.ps1 +++ b/habitat/plan.ps1 @@ -43,7 +43,6 @@ function Invoke-Build { bundle config --local jobs 4 bundle config --local retry 5 bundle config --local silence_root_warning 1 - bundle config set --local force_ruby_platform false Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies" bundle install @@ -68,7 +67,7 @@ function Invoke-Install { Push-Location $pkg_prefix bundle config --local gemfile $project_root/Gemfile Write-BuildLine "** generating binstubs for chef-cli with precise version pins" - Write-BuildLine "** generating binstubs for chef-cli with precise version pins $project_root $pkg_prefix/bin " + Write-BuildLine "** generating binstubs for chef-cli with precise version pins $project_root $pkg_prefix/bin " Invoke-Expression -Command "appbundler.bat $project_root $pkg_prefix/bin chef-cli" If ($lastexitcode -ne 0) { Exit $lastexitcode } Write-BuildLine " ** Running the chef-cli project's 'rake install' to install the path-based gems so they look like any other installed gem."