ERROR: Failed to build gem native extension

Hello all,
I tried to install the ‘amatch’ gem and received the following error:

===============================================================================
C:\Ruby\bin>gem install amatch-0.2.3.gem
Building native extensions. This could take a while…
ERROR: Error installing amatch-0.2.3.gem:
ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb
creating Makefile

nmake
‘nmake’ is not recognized as an internal or external command,
operable program or batch file.

Gem files will remain installed in
C:/Ruby/lib/ruby/gems/1.8/gems/amatch-0.2.3 for inspection.
Results logged to
C:/Ruby/lib/ruby/gems/1.8/gems/amatch-0.2.3/ext/gem_make.out

==============================================================================
I copied the .gem file to the C:\Ruby\bin\ folder and executed the
install from there.
I’ve done all the updates and still get the same error.

I don’t know what I’m doing wrong.
Any help is appreciated.

JohnM

It means you can’t compile the binary gem, probably because you are on
windows. You can try:

gem install amatch-0.2.3.gem --platform=mswin32

… which will force a platform (if the author provided that in their
gem) …

Otherwise, you have to build the gem yourself from source.

Thanks for the quick reply.

I tried what you stated with no change.

I installed the .tgz of the gem and moved the entire folder within the
bin folder.
I read the ‘readme’ and tried to install. I received the below error
after the setup command.
Is this what you mean by “you have to build the gem yourself from
source”?

JohnM

===========================================================================
C:\Ruby\bin\amatch-0.2.3>ruby install.rb config
install.rb: entering config phase…
—> bin
<— bin
—> ext
C:/Ruby/bin/ruby C:/Ruby/bin/amatch-0.2.3/ext/extconf.rb
creating Makefile
<— ext
install.rb: config done.

C:\Ruby\bin\amatch-0.2.3>ruby install.rb setup
install.rb: entering setup phase…
—> bin
set #! line to “#!C:/Ruby/bin/ruby” for
C:/Ruby/bin/amatch-0.2.3/bin/agrep.rb …
rm -f agrep.rb.tmp
<— bin
—> ext
make
setup failed
‘system make’ failed
try ‘ruby install.rb --help’ for usage

=============================================================================

Älphä Blüë wrote:

It means you can’t compile the binary gem, probably because you are on
windows. You can try:

gem install amatch-0.2.3.gem --platform=mswin32

… which will force a platform (if the author provided that in their
gem) …

Otherwise, you have to build the gem yourself from source.

Hi John,

You are on windows so you are most likely using nmake not make.
Secondly, you need to have a c-compiler on your system and in your path
in order for nmake to be used.

But, you should take a step back for a moment. First, this is a Ruby
issue and you are on a rails forum so you aren’t going to get much
feedback here. You should probably post something in the “ruby” forum.

Secondly, you need to list what Ruby version you are using, what windows
version you are using because that does matter. On windows, Ruby
versions are generally now compiled with mingw and if you are using
later platforms like 1.9x then you have to have the mingw compiler as
well which comes with the devkit.

Ruby is not “windows” friendly. It is far from windows friendly.
Unless you have the correct devkits, the correct compilers, it can
create many issues for you. If you are using the 1.8.6 one-click
installer then you should be ‘fairly safe’ for the most part from much
of these frustrations. However, it won’t exempt you from having issues
with gems that won’t compile correctly.

Generally I do the following in order:

gem install (gemname)
… if that fails…
gem install (gemname) --platform=mswin32
… if that fails…
gem install (gemname) --platform mswin32 --source http://gem_source_url

You should make sure that you have your gem sources updated for
starters:

gem sources -a http://gems.github.com (you only do this once)

This is the primary source now for retrieving most gems.

Other than that, compiling gems from binaries are difficult to explain
and again, it would depend on what compiler you are using, what ruby
version you are using, and what windows platform you are using.

If you are using Ruby 1.9 you can check most gems from
http://isitruby.com and validate whether or not those gems are working
for 1.9. If you are using 1.8 a lot of the gem frustrations can simply
be due to the fact that a lot of authors could care less about making
their gems usable for windows. There’s a lot of discussions about gem
building and many authors never follow the same exact standards.

Let me know if I can help you further with this issue.

John M. wrote:

Thanks again for the quick reply.
You are right. This is not the place for this post. My apologies.
I will move to the appropriate forum.
The funny thing is that I’m running a VM of Windows 2003 on a MAC.
I’m really a PHP guy with around 2 weeks (department mandated) of Ruby
experience.
Thanks again.
JohnM

No problem John -

I visit pretty much all forums and there are some great guys over there
that can assist. Luis L. and Roger P. are pretty much the experts
on ruby platform and the state of the windows one click installer over
in the ruby forums.

I’ve built 1.9.1 via mingw and I’ve also managed to half build my own
1.9.1 via vc8 which took about 1 month trying to update/upgrade and
install various libraries that ruby requires, zlib, iconv, readline,
etc.

Trust me on the frustrations mate :slight_smile:

As a windows user, I feel very unloved. I think it comes down to just
developing on the type of system you will be go to production on. If
your server is on linux for instance, develop using a vmware or
virtualbox distro of the same version.

However, I tend to do both. I develop on windows and on linux (I just
prefer windows development over linux due to familiarity).

At least with MAC you have textmate :slight_smile:

nmake
‘nmake’ is not recognized as an internal or external command,
operable program or batch file.

Appears you don’t have a build environment installed, and that amatch
doesn’t give you any binaries, meaning…you need a build
environment :slight_smile:
As alpha Blue noted, the easiest way is to download/install mingw +
devkit [devkit is mingw compiler] and hope it builds at that point, or
switch to linux or cygwin [or drop that extension].

=r

Thanks for the advice. I will try all that’s suggested.
I’ve also posted on the Ruby forum, since Apha Blue’s earlier post.
It seems that I have a bit of work ahead of me.
Thanks again.

johnM

rogerdpack wrote:

nmake
‘nmake’ is not recognized as an internal or external command,
operable program or batch file.

Appears you don’t have a build environment installed, and that amatch
doesn’t give you any binaries, meaning…you need a build
environment :slight_smile:
As alpha Blue noted, the easiest way is to download/install mingw +
devkit [devkit is mingw compiler] and hope it builds at that point, or
switch to linux or cygwin [or drop that extension].
Programming gone awry: ruby 1.9 one click installer
=r

Thanks again for the quick reply.
You are right. This is not the place for this post. My apologies.
I will move to the appropriate forum.
The funny thing is that I’m running a VM of Windows 2003 on a MAC.
I’m really a PHP guy with around 2 weeks (department mandated) of Ruby
experience.
Thanks again.
JohnM

Älphä Blüë wrote:

Hi John,

You are on windows so you are most likely using nmake not make.
Secondly, you need to have a c-compiler on your system and in your path
in order for nmake to be used.

But, you should take a step back for a moment. First, this is a Ruby
issue and you are on a rails forum so you aren’t going to get much
feedback here. You should probably post something in the “ruby” forum.

Secondly, you need to list what Ruby version you are using, what windows
version you are using because that does matter. On windows, Ruby
versions are generally now compiled with mingw and if you are using
later platforms like 1.9x then you have to have the mingw compiler as
well which comes with the devkit.

Ruby is not “windows” friendly. It is far from windows friendly.
Unless you have the correct devkits, the correct compilers, it can
create many issues for you. If you are using the 1.8.6 one-click
installer then you should be ‘fairly safe’ for the most part from much
of these frustrations. However, it won’t exempt you from having issues
with gems that won’t compile correctly.

Generally I do the following in order:

gem install (gemname)
… if that fails…
gem install (gemname) --platform=mswin32
… if that fails…
gem install (gemname) --platform mswin32 --source http://gem_source_url

You should make sure that you have your gem sources updated for
starters:

gem sources -a http://gems.github.com (you only do this once)

This is the primary source now for retrieving most gems.

Other than that, compiling gems from binaries are difficult to explain
and again, it would depend on what compiler you are using, what ruby
version you are using, and what windows platform you are using.

If you are using Ruby 1.9 you can check most gems from
http://isitruby.com and validate whether or not those gems are working
for 1.9. If you are using 1.8 a lot of the gem frustrations can simply
be due to the fact that a lot of authors could care less about making
their gems usable for windows. There’s a lot of discussions about gem
building and many authors never follow the same exact standards.

Let me know if I can help you further with this issue.

I would stay away from cygwin completely. Cygwin is not in the same
thought process with how ruby is being packaged in windows. The people
behind build packaging are moving away from cygwin and staying with
mingw.

So, the best advice is to stick with mingw and the devkit and bypass
cygwin altogether. In fact, if you have cygwin installed and in your
windows path, remove it. It will only cause issues during build phases
as it may accidentally have its compiler picked up instead.

Windows = mingw+devkit