Can't Find ffi.h When Installing ffi ruby gem

2019-07-09 04:01发布

Ruby version 2.2.4p230

RubyGem version 2.7.2

Ruby-devel and lib64ffi-devel installed.

64-bit OpenMandriva 3.0, urpmi and rpmdrake used.

Goal: to install compass, but the gem ffi is needed first.

I have scoured the internet so hard for the last two days and I'm so stumped... It's impossible for me to install an earlier version of ruby because of the dependency for an older ncurses. I feel like replacing ncurses would open a can of nasty worms.

However... I am also completely open to a compass alternative, where the config.rb project files could be somehow ported / copied so both compass and this other sass compiler could operate. (this is for work and we're not changing the sass builder any time soon).

/usr/share/gems/gems/ffi-1.9.18/ext/ffi_c totally exists, there is an ffi.c file in that directory but can't find any ffi.h file in the vicinity. In a moment of desperation I touched ffi.h in that dir and when I ran gem install it removed it. ;) I would try taking a copy of someone else's libs to see if that works.

Basically any way to get this working without breaking the rest of my packages. I don't use ruby for anything else, just compass.

Here is the output:

# sudo gem install ffi
Building native extensions. This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

current directory: /usr/share/gems/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby -r ./siteconf20171110-17988-1lodsok.rb extconf.rb
checking for ffi.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib64
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/$(RUBY_BASE_NAME)
    --with-ffi_c-dir
    --without-ffi_c-dir
    --with-ffi_c-include
    --without-ffi_c-include=${ffi_c-dir}/include
    --with-ffi_c-lib
    --without-ffi_c-lib=${ffi_c-dir}/lib64
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/share/ruby/mkmf.rb:587:in `try_cpp'
    from /usr/share/ruby/mkmf.rb:1060:in `block in have_header'
    from /usr/share/ruby/mkmf.rb:911:in `block in checking_for'
    from /usr/share/ruby/mkmf.rb:351:in `block (2 levels) in postpone'
    from /usr/share/ruby/mkmf.rb:321:in `open'
    from /usr/share/ruby/mkmf.rb:351:in `block in postpone'
    from /usr/share/ruby/mkmf.rb:321:in `open'
    from /usr/share/ruby/mkmf.rb:347:in `postpone'
    from /usr/share/ruby/mkmf.rb:910:in `checking_for'
    from /usr/share/ruby/mkmf.rb:1059:in `have_header'
    from extconf.rb:16:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/lib64/gems/ruby/ffi-1.9.18/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/share/gems/gems/ffi-1.9.18 for inspection.
Results logged to /usr/lib64/gems/ruby/ffi-1.9.18/gem_make.out

Any help appreciated!

1条回答
啃猪蹄的小仙女
2楼-- · 2019-07-09 04:37

Your error message shows:

/usr/share/ruby/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first.

And that's how you can solve it:

xcode-select --install

(but make sure beforehand that xcode-select -p is returning the path to a stable Xcode version, like Xcode 10)

See also https://github.com/ffi/ffi/issues/647.

查看更多
登录 后发表回答