# Rubyzip installation error

**URL:** <https://discourse.chef.io/t/rubyzip-installation-error/10356>\
**Category:** Chef Infra (archive)\
**Created:** [February 3, 2017, 9:13am UTC](https://discourse.chef.io/t/rubyzip-installation-error/10356 "2017-02-03T09:13:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aparna11jha](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@aparna11jha](https://discourse.chef.io/u/aparna11jha)\
**Post date:** [February 3, 2017, 9:13am UTC](https://discourse.chef.io/t/rubyzip-installation-error/10356/1 "2017-02-03T09:13:24Z")

</div>

I am using zipfile cookbook to unzip a package on Windows 2012 R2.  
I execute the cookbook through Jenkins while bootstrapping the node itself.  
Post bootstrapping, when the cookbook is about to start executing, it is trying to install rubyzip on the node and throws error " failed to allocate memory".

Below is the error that I am coming across

[2017-02-03T08:31:56+00:00] INFO: Processing chef\_gem[rubyzip] action install (c:/chef/cache/cookbooks/zipfile/providers/default.rb line 22)  
[FATAL] failed to allocate memory  
+ CategoryInfo : NotSpecified: ([FATAL] failed to allocate memory  
:String) [], RemoteException  
+ FullyQualifiedErrorId : NativeCommandError  
+ PSComputerName : {IP Address}

Please help me in resolving this issue.

---

<div class="post-metadata">

**Author:** ![svucich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/svucich/32/1717_2.png) [@svucich](https://discourse.chef.io/u/svucich)\
**Post date:** [February 7, 2017, 2:23am UTC](https://discourse.chef.io/t/rubyzip-installation-error/10356/2 "2017-02-07T02:23:19Z")

</div>

I use chocolatey to install 7-zip, then the seven\_zip cookbook, available via the surpermarket (Needs a depends in the metadata of what ever cookbook you call/create with this in it).

Here is the basics of what I have done in the past (Sorry i can’t help to much with your error, hence this workaround).

```
# Make sure chocolatey is installed
include_recipe 'chocolatey'

# Install 7zip
chocolatey '7zip' do
  action :install
end

# Extract the archive in preparation for what ever. Change the options as you see fit!
# There is a not_if statement at the end - You will also need to change this to suit your requirementsor the bloack won't run
seven_zip_archive 'oracle_rdbms_installer' do
  path 'c:\applications'
  source 'c:\applications\oracle12c_winx64.zip'
  action :extract
  not_if { ::File.directory?('C:\applications\oracle12c_winx64') == true }
end

```

this should achieve some similar end results based on what I assume you are trying to achieve.

Good luck!

---

<div class="post-metadata">

**Author:** ![kswem](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@kswem](https://discourse.chef.io/u/kswem)\
**Post date:** [February 7, 2017, 10:37pm UTC](https://discourse.chef.io/t/rubyzip-installation-error/10356/3 "2017-02-07T22:37:09Z")

</div>

You can also use PowerShell and .NET (both already on Server 2012) to handle your ZIP files so you don’t have to rely on any external zip cookbook or rubyzip. If you have PowerShell 5.0 on Server 2012 (PS 4.0 is the default) then you can use PS 5’s native zip cmdlets, otherwise use .NET to handle the un-zipping.

Here is an example of what we use:

```
powershell_script 'Unzip file' do
  code '
    $ZipFile = <path to zip>
    $OutFolder = <path to output folder>
    If ($host.version.major -ge "5")
    {
      Expand-Archive -Path $ZipFile -DestinationPath $OutFolder -Force
    }
    ElseIf ($host.version.major -ge "3") 
    {
      Add-Type -AssemblyName System.IO.Compression.FileSystem
      $ZipFile = GCI ./*.zip
      [System.IO.Compression.ZipFile]::ExtractToDirectory($ZipFile, $OutFolder)
    }
  '
end

```

Hope this helps.
