views:

965

answers:

1

About a month ago I installed libxml-ruby using gem install libxml-ruby and it worked fine. Then i went to install it on another machine today and it failed with this error:

C:\Windows\system32>gem install -r libxml-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
        ERROR: Failed to build gem native extension.

c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake RUBYARCHDIR=c:/ruby/lib/ruby/
gems/1.8/gems/libxml-ruby-1.1.3-x86-mswin32-60/lib RUBYLIBDIR=c:/ruby/lib/ruby/g
ems/1.8/gems/libxml-ruby-1.1.3-x86-mswin32-60/lib
'c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake' is not recognized as an int
ernal or external command,
operable program or batch file.


Gem files will remain installed in c:/ruby/lib/ruby/gems/1.8/gems/libxml-ruby-1.
1.3-x86-mswin32-60 for inspection.
Results logged to c:/ruby/lib/ruby/gems/1.8/gems/libxml-ruby-1.1.3-x86-mswin32-6
0/ext/mingw/gem_make.out

I have rake installed and win32-api

I then got confused if I had really installed libxml-ruby on my machine previously and tried uninstalling and reinstalling it. It now fails with the same error message on my machine and some scripts i've written to parse xml, which used to work, no longer work. Has anyone else tried installing libxml-ruby lately on windows xp? It appears to be completely broken.

+4  A: 

I got the same problem, and ended up figuring out a decent work-around.

It seems the error is correct

'c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake'

isn't a valid executable. It needs to run rake from the root ruby/bin folder, where the wrapping batch file can be found.

Rummaging through the rubygems code, I found that Gem::Ext::RakeBuilder tries to build extensions using

cmd = ENV['rake'] || Gem.bin_path('rake') rescue Gem.default_exec_format % 'rake'

So, simply setting the rake environment variable to something valid before running the gem install should help:

C:\>set rake=c:\ruby-1.8.6-26\bin\rake.bat

C:\>gem install libxml-ruby --no-rdoc --no-ri
Building native extensions.  This could take a while...
Successfully installed libxml-ruby-1.1.3-x86-mswin32-60
1 gem installed

(I skipped installing rdoc and ri because it prints out a bunch of formatting warnings, making it more difficult to paste the results in here.)

Nick Desjardins
had the same issue as well, and this worked for me.
catalpa
Thank you for the tip with "set rake=..", Nick ! It works just fine.
Dr1Ku