6

I'm trying to install win32-api gem on my machine and I'm facing some issues when building native extensions:

$ gem install win32-api --no-ri --rdoc
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
C:\Programs\dev_kit\bin\make.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0
ERROR:  Error installing win32-api:
        ERROR: Failed to build gem native extension.

        c:/Programs/ruby/bin/ruby.exe extconf.rb
checking for strncpy_s()... no
creating Makefile

make
      0 [main] us 0 init_cheap: VirtualAlloc pointer is null, Win32 error 487
AllocationBase 0x0, BaseAddress 0x60E90000, RegionSize 0x170000, State 0x10000
C:\Programs\dev_kit\bin\make.exe: *** Couldn't reserve space for cygwin's heap, Win32 error 0

This problem happens when installing any gem that tries to compile a native extension, like json or win32-api, for instance.

I already tried to change the size of virtual memory of this machine, but it didn't work.

My configuration:

  • Ruby version: 1.8.7p371
  • Gem version: 1.8.24
  • Bash 3.1.0
  • DevKit 4.5.2
  • Windows 7 x64
Glauco Vinicius
  • 2,447
  • 1
  • 21
  • 37
  • If it's not too disruptive for future people dropping by this question, try a reboot first. I ended up uninstalling/re-installing and coming to the same error... 1 reboot, all fixed. Another similar question: http://stackoverflow.com/questions/18502999/git-extensions-win32-error-487-couldnt-reserve-space-for-cygwins-heap-win32/31970708#31970708 – kayleeFrye_onDeck May 01 '17 at 20:21

1 Answers1

12

I was facing the exact same issue and after making a lot of searches and many different tries, this is what fixed it for me:

  1. Download rebase from http://www.tishler.net/jason/software/rebase/ (download the latest *.exe version) and run it.

  2. Fire up a Prompt ("Run as administrator") and go to your dev-kit folder (for instance, mine was C:\Programs\dev_kit)

  3. While in the dev-kit folder, run devkitvars.bat to add devkit to the path.

  4. Now do a cd bin (it got me to C:\Programs\dev_kit\bin) and from there run:

    rebase -b 0x30000000 msys-1.0.dll
    

Try to install the gems again. Instead of seeing an error message, now you should see Building native extensions. This could take a while... and it will hang for a while there.

Your gem should be successfully installed after a couple of minutes/seconds. No more headaches :)

Nicholas Pufal
  • 2,045
  • 18
  • 23
  • 2
    For me, in devkit bin directory, the administrator propmt doesn't recognize 'rebase'... – user1364684 Feb 13 '14 at 17:28
  • After running this, the original problem went away, but then I started seeing errors containing "*** target pattern contains no '%'". The easiest fix I found was to downgrade RubyGems using `gem update --system 2.3.0`. Details [here](https://github.com/rubygems/rubygems/issues/977). – dmccabe Dec 03 '14 at 17:26
  • This throws errors about `cygwin1.dll is missing fromyour computer` when trying to run rebase... – kayleeFrye_onDeck May 01 '17 at 19:45