views:

634

answers:

2

I am trying to install a ruby gem. I am getting this error.

C:\>gem install racc
Building native extensions.  This could take a while...
ERROR:  Error installing racc:
        ERROR: Failed to build gem native extension.

c:/ruby/bin/ruby.exe extconf.rb install racc
extconf.rb:3:in ``': No such file or directory - uname -p (Errno::ENOENT)
        from extconf.rb:3


Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/racc-1.4.6 for inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/racc-1.4.6/ext/racc/cparse/gem_make.out

I have searched this site, but found nothing about it. I have googled too, and found only that updating ruby gems should solve the problem, but it did not.

I have ruby gems 1.2.0 and ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32], Windows 2003.

+2  A: 

The offending line in the extconf.rb file in the racc gem is this:

ENV["ARCHFLAGS"] = "-arch #{`uname -p` =~ /powerpc/ ? 'ppc' : 'i386'}"

Since you are not using a PowerPC (unless your setup is exceptionally unusual :) ), you can replace this line with:

ENV["ARCHFLAGS"] = "-arch i386"

I don't know if it will compile successfully now, but at least you'll be past this error.

Daniel Lucraft
Thanks. That fixed the error, but I get another one this time. :)
Željko Filipin
More info: Download racc-1.4.6.tgz from http://rubyforge.org/frs/?group_id=7299. Extract. Change ENV["ARCHFLAGS"] line in racc-1.4.6\ext\racc\cparse\extconf.rb. Open command prompt at racc-1.4.6 folder. Execute `rake gem`. in command prompt go to racc-1.4.6\pkg. Execute `gem install racc`.
Željko Filipin
The next error was that nmake is not installed. After I installed it, I got error that cl is not installed. I give up.
Željko Filipin
+1  A: 

This may not be directly related to this post but it helped me and i hope may help others who have had the "Failed to build gem native extension." error when installing gems on Windows.

The guys over at rubyinstaller.org provide a DevKit (http://rubyinstaller.org/download.html) containing GCC, Make and Sh for use when installing Gems. I followed the instructions for installing (http://wiki.github.com/oneclick/rubyinstaller/development-kit) and hey presto... gems that previously wouldn't install now install with no errors.

I've tested installing the RACC gem and had no problems (although i have no previous experience with this gem; maybe it has been fixed since.) I've also tested with RCOV (which i've never been able to get working correctly) and have managed to install it with no errors!

Hope this helps someone out there ;)

Jim McKerchar