jaym / busser-pester

A busser runner plugin that can run pester tests
Other
1 stars 2 forks source link

PostInstall does not work on 64-bit Ruby due to sysnative not existing #5

Open KierranM opened 8 years ago

KierranM commented 8 years ago

When running test-kitchen using the latest chef omnibus install busser-pester fails during the post install step because it is using the C:\windows\sysnative path to powershell, which works as expected when using 32-bit Ruby on 64-bit Windows.

However, now that the latest chef omnibus installer installs a 64-bit Ruby, the sysnative path will no longer work and you get the error seen below. To fix this, we need to these three lines:

A possible solution to this would be to use the correct path depending on which version of Windows you are using. Something like this would be a nice solution:

require 'rbconfig'
def powershell
  case RbConfig::CONFIG['host_vendor']
  when 'w64' # 64-bit Ruby
    'c:\windows\system32\windowspowershell\v1.0\powershell.exe'
  else # Assume 32-bit Ruby
    'c:\windows\sysnative\windowspowershell\v1.0\powershell.exe'
  end
end

download_psget = <<-DOWNLOADPSGET 
      #{powershell} -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command "if (-not (get-module -list pester)) {iex (new-object Net.WebClient).DownloadString('http://bit.ly/GetPsGet')}"
    DOWNLOADPSGET

Stacktrace

-----> Converging <default-windows-2012r2>...
       Preparing files for transfer
       Preparing dna.json
       Berksfile, Cheffile, cookbooks/, or metadata.rb not found so Chef will run with effectively no cookbooks. Is this intended?
       Removing non-cookbook files before transfer
       Preparing solo.rb
-----> Installing Chef Omnibus ()

       Downloading package from https://packages.chef.io/stable/windows/2012r2/chef-client-12.9.38-1-x64.msi

       Download complete.

       Skipping md5 verification

       Installing Chef Omnibus package C:\Users\ADMINI~1\AppData\Local\Temp\chef-.msi

       Installation complete

       Transferring files to <default-windows-2012r2>
       Starting Chef Client, version 12.9.38
       Installing Cookbook Gems:
       Compiling Cookbooks...
       Converging 0 resources

       Running handlers:
       Running handlers complete
       Chef Client finished, 0/0 resources updated in 31 seconds
       Finished converging <default-windows-2012r2> (1m54.37s).
-----> Setting up <default-windows-2012r2>...
       Finished setting up <default-windows-2012r2> (0m0.00s).
-----> Verifying <default-windows-2012r2>...
       Preparing files for transfer
-----> Installing Busser (busser)

       Successfully installed thor-0.19.0
       Successfully installed busser-0.7.1
       2 gems installed
       Installing Busser plugins: busser-pester busser-serverspec

       Plugin pester installed (version 0.0.8)
-----> Running postinstall for pester plugin
-----> [pester] Installing PsGet
$$$$$$ busser.bat : The system cannot find the path specified.
$$$$$$ At line:26 char:1
$$$$$$ + &amp; "$busser" plugin install $plugins.Split() 2&gt;&amp;1
$$$$$$ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$$$$$$     + CategoryInfo          : NotSpecified: (The system cann...path specified.
$$$$$$    :String) [], RemoteException
$$$$$$     + FullyQualifiedErrorId : NativeCommandError
$$$$$$ 
$$$$$$ !!!!!! Command [
$$$$$$ c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -NonInteractive
$$$$$$ -NoProfile -ExecutionPolicy Bypass -Command "if (-not (get-module -list
$$$$$$ pester)) {iex (new-object
$$$$$$ Net.WebClient).DownloadString('http://bit.ly/GetPsGet')}"
-----> Destroying <default-windows-2012r2>...
EasyAsABC123 commented 8 years ago

I'm having the same issue

jaym commented 8 years ago

I don't think using this repo is the correct thing to do these days. You should be using https://github.com/test-kitchen/kitchen-pester