Skip to content

Instantly share code, notes, and snippets.

@swade1987
Last active May 9, 2016 18:47
Show Gist options
  • Select an option

  • Save swade1987/4e145ac8e1483d982864 to your computer and use it in GitHub Desktop.

Select an option

Save swade1987/4e145ac8e1483d982864 to your computer and use it in GitHub Desktop.
ChefSpec "powershell_script" error
Failures:
1) gocd-agent::default When all attributes are default, on an unspecified platform includes dependent recipes
Failure/Error: runner.converge(described_recipe)
Mixlib::ShellOut::ShellCommandFailed:
Expected process to exit with [0], but received '127'
---- Begin output of powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None -Command "[System.Environment]::GetEnvironmentVariable('ChocolateyInstall', 'MACHINE')" ----
STDOUT:
STDERR: sh: powershell.exe: command not found
---- End output of powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None -Command "[System.Environment]::GetEnvironmentVariable('ChocolateyInstall', 'MACHINE')" ----
Ran powershell.exe -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Unrestricted -InputFormat None -Command "[System.Environment]::GetEnvironmentVariable('ChocolateyInstall', 'MACHINE')" returned 127
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/libraries/helpers.rb:40:in `env_var'
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/libraries/helpers.rb:36:in `machine_env_var'
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/libraries/helpers.rb:9:in `block in chocolatey_install'
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/libraries/helpers.rb:9:in `fetch'
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/libraries/helpers.rb:9:in `chocolatey_install'
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/libraries/helpers.rb:26:in `chocolatey_installed?'
# /var/folders/wl/r_v783rd2cd8jllgv1426mx40000gn/T/d20160322-3169-1h8fmk5/cookbooks/chocolatey/recipes/default.rb:33:in `block (2 levels) in from_file'
# ./spec/unit/recipes/default_spec.rb:23:in `block (3 levels) in <top (required)>'
# ./spec/unit/recipes/default_spec.rb:27:in `block (3 levels) in <top (required)>'
node.override['gocd']['agent']['go_server_host'] = 'gocd.uk.org'
node.override['gocd']['agent']['package_file']['url'] = 'https://download.go.cd/binaries/16.2.1-3027/win/go-agent-16.2.1-3027-setup.exe'
include_recipe 'gocd::agent'
# Construct the ".chef" directory.
powershell_script 'write-to-interpolated-path' do
code <<-EOH
New-Item -ItemType Directory -Force -Path C:/.chef
EOH
end
#
# Cookbook Name:: gocd-agent
# Spec:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
require 'spec_helper'
RSpec.configure do |config|
config.platform = 'windows'
config.version = '2012R2'
end
describe 'gocd-agent::default' do
context 'When all attributes are default, on an unspecified platform' do
let(:chef_run) do
runner = ChefSpec::ServerRunner.new
runner.node.automatic['platform_family'] = 'windows'
runner.node.automatic['platform'] = 'windows'
runner.node.automatic['os'] = 'windows'
runner.node.set['gocd']['agent']['go_server_host'] = 'gocd.ukpds.org'
runner.node.set['gocd']['agent']['package_file']['url'] = 'https://download.go.cd/binaries/16.2.1-3027/win/go-agent-16.2.1-3027-setup.exe'
runner.converge(described_recipe)
end
it 'includes dependent recipes' do
expect(chef_run).to include_recipe('gocd::agent')
end
it 'executes the write-to-interpolated-path powershell script' do
expect(chef_run).to run_powershell_script('write-to-interpolated-path')
end
end
end
@spuder
Copy link

spuder commented Apr 13, 2016

I'm running into the same problem.

   STDERR: sh: powershell.exe: command not found

Did you ever work around this?

@BruceCutler
Copy link

I also have this issue, did either of you make any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment