Productively Distracted
Posted Wednesday October 5, 2011 around 10:22 PM

I have been struggling with an error installing FFI for several days. When I run gem install ffi I get the following error:

$ gem install ffi
Fetching: ffi-1.0.11.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

        /Users/jwebb/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include... no
checking for rb_thread_blocking_region()... yes
checking for ruby_thread_has_gvl_p()... yes
checking for ruby_native_thread_p()... yes
checking for rb_thread_call_with_gvl()... yes
creating extconf.h
creating Makefile

Configuring libffi
cd "/Users/jwebb/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/ext/ffi_c/libffi" && make
make "AR_FLAGS=" "CC_FOR_BUILD=" "CFLAGS=" "CXXFLAGS=" "CFLAGS_FOR_BUILD=" "CFLAGS_FOR_TARGET=" "INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m 644" "INSTALL_PROGRAM=/usr/bin/install -c" "INSTALL_SCRIPT=/usr/bin/install -c" "JC1FLAGS=" "LDFLAGS=" "LIBCFLAGS=" "LIBCFLAGS_FOR_TARGET=" "MAKE=make" "MAKEINFO=/bin/sh /Users/jwebb/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/ext/ffi_c/libffi/missing --run makeinfo " "PICFLAG=" "PICFLAG_FOR_TARGET=" "RUNTESTFLAGS=" "SHELL=/bin/sh" "exec_prefix=/usr/local" "infodir=/usr/local/share/info" "libdir=/usr/local/lib" "prefix=/usr/local" "AR=ar" "AS=as" "CC=/usr/bin/gcc-4.2" "CXX=g++" "LD=ld" "NM=/usr/bin/nm" "RANLIB=ranlib" "DESTDIR=" all-recursive
Making all in include
make[3]: Nothing to be done for `all'.
Making all in testsuite
make[3]: Nothing to be done for `all'.
Making all in man
make[3]: Nothing to be done for `all'.
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/debug.lo src/debug.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/debug.c  -fno-common -DPIC -o src/.libs/debug.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/prep_cif.lo src/prep_cif.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/prep_cif.c  -fno-common -DPIC -o src/.libs/prep_cif.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/types.lo src/types.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/types.c  -fno-common -DPIC -o src/.libs/types.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/raw_api.lo src/raw_api.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/raw_api.c  -fno-common -DPIC -o src/.libs/raw_api.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/java_raw_api.lo src/java_raw_api.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/java_raw_api.c  -fno-common -DPIC -o src/.libs/java_raw_api.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/closures.lo src/closures.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/closures.c  -fno-common -DPIC -o src/.libs/closures.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/x86/ffi.lo src/x86/ffi.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/x86/ffi.c  -fno-common -DPIC -o src/x86/.libs/ffi.o
/bin/sh ./libtool   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -I. -I./include -Iinclude -I./src  -c -o src/x86/darwin.lo src/x86/darwin.S
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I. -I./include -Iinclude -I./src -c src/x86/darwin.S  -fno-common -DPIC -o src/x86/.libs/darwin.o
/bin/sh ./libtool --tag=CC   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -Wall -g -fexceptions  -c -o src/x86/ffi64.lo src/x86/ffi64.c
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -Wall -g -fexceptions -c src/x86/ffi64.c  -fno-common -DPIC -o src/x86/.libs/ffi64.o
/bin/sh ./libtool   --mode=compile /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I.  -I. -I./include -Iinclude -I./src  -I. -I./include -Iinclude -I./src  -c -o src/x86/darwin64.lo src/x86/darwin64.S
libtool: compile:  /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I. -I./include -Iinclude -I./src -I. -I./include -Iinclude -I./src -c src/x86/darwin64.S  -fno-common -DPIC -o src/x86/.libs/darwin64.o
/bin/sh ./libtool --tag=CC   --mode=link /usr/bin/gcc-4.2 -Wall -g -fexceptions  -version-info `grep -v '^#' ./libtool-version`   -o -rpath /usr/local/lib src/debug.lo src/prep_cif.lo src/types.lo src/raw_api.lo src/java_raw_api.lo src/closures.lo      src/x86/ffi.lo src/x86/darwin.lo src/x86/ffi64.lo src/x86/darwin64.lo
libtool: link: too many parameters to `-version-info'
libtool: link: Try `libtool --help --mode=link' for more information.
make[3]: *** [] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** ["/Users/jwebb/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/ext/ffi_c/libffi"/.libs/libffi_convenience.a] Error 2

Gem files will remain installed in /Users/jwebb/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11 for inspection.
Results logged to /Users/jwebb/.rvm/gems/ruby-1.9.2-p290/gems/ffi-1.0.11/ext/ffi_c/gem_make.out

After some digging around and changing random things I found the issue. In my .bash_profile I had the following line:

export GREP_OPTIONS='-n --color=always'

I don't know why exactly (though I have some vague suspicions) but this causes the build to fail. Removing the -n switch and restarting the bash session clears the issue right up.

blog comments powered by Disqus