ruby - ffi Ruby Gem 编译失败

标签 ruby rubygems jekyll ffi libffi

尝试安装 jekyll 主题 bundle install 命令失败,出现以下错误:

Fetching ffi 1.12.2 (was 1.11.3)
Installing ffi 1.12.2 (was 1.11.3) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /srv/dev-disk-by-label-data/home/mark/gems/gems/ffi-1.12.2/ext/ffi_c
/usr/local/rvm/rubies/ruby-2.6.0/bin/ruby -I /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200226-30145-3rdfp2.rb extconf.rb
/usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:1565: warning: Insecure world writable dir /srv/dev-disk-by-label-data/home/mark/gems/bin in PATH, mode 040777
*** 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}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/rvm/rubies/ruby-2.6.0/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}/lib
    --enable-system-libffi
    --disable-system-libffi
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
    from extconf.rb:9:in `system_libffi_usable?'
    from extconf.rb:34:in `<main>'

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

  /srv/dev-disk-by-label-data/home/mark/gems/extensions/x86-linux/2.6.0/ffi-1.12.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /srv/dev-disk-by-label-data/home/mark/gems/gems/ffi-1.12.2 for inspection.
Results logged to /srv/dev-disk-by-label-data/home/mark/gems/extensions/x86-linux/2.6.0/ffi-1.12.2/gem_make.out

An error occurred while installing ffi (1.12.2), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.12.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  minimal-mistakes-jekyll was resolved to 4.18.1, which depends on
    jekyll-feed was resolved to 0.13.0, which depends on
      jekyll was resolved to 4.0.0, which depends on
        jekyll-sass-converter was resolved to 2.1.0, which depends on
          sassc was resolved to 2.2.1, which depends on
            ffi

所以我试着按照它的建议去做:

$ gem install ffi -v '1.12.2' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
/usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /srv/dev-disk-by-label-data/home/mark/gems/bin in PATH, mode 040777
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

    current directory: /srv/dev-disk-by-label-data/home/mark/gems/gems/ffi-1.12.2/ext/ffi_c
/usr/local/rvm/rubies/ruby-2.6.0/bin/ruby -I /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200226-30498-uxx1at.rb extconf.rb
/usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:1565: warning: Insecure world writable dir /srv/dev-disk-by-label-data/home/mark/gems/bin in PATH, mode 040777
*** 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}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/rvm/rubies/ruby-2.6.0/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}/lib
    --enable-system-libffi
    --disable-system-libffi
    --with-libffi-config
    --without-libffi-config
    --with-pkg-config
    --without-pkg-config
/usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:552:in `try_link0'
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
    from /usr/local/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
    from extconf.rb:9:in `system_libffi_usable?'
    from extconf.rb:34:in `<main>'

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

  /srv/dev-disk-by-label-data/home/mark/gems/extensions/x86-linux/2.6.0/ffi-1.12.2/mkmf.log

extconf failed, exit code 1

“To see why this extension failed to compile”这句话听起来很有趣,但日志文件只包含:

pkg-config --exists libffi"
| pkg-config --libs libffi
=> "-lffi\n"
"gcc -o conftest -I/usr/local/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/i686-linux -I/usr/local/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/ruby/backward -I/usr/local/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0 -I.  -$
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

我安装了 ruby-dev 包。 我不清楚它失败的原因。

最佳答案

对于正在寻找解决方案的任何其他人,这对我有帮助。

gem install ffi -- --disable-system-libffi

或特定版本

gem install ffi -v '1.13.1' -- --disable-system-libffi

https://medium.com/@leoliang.climber/missing-ffi-prep-closure-error-for-ffi-1-13-1-gem-70f800a48090

关于ruby - ffi Ruby Gem 编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60406620/

相关文章:

ruby-on-rails - 有没有办法预处理 ruby​​ 代码并找到运行时会发生的错误?

ruby-on-rails - Rails 命令无法正常工作

rubygems - 无法安装 RubyGems 2.0.0,因为 'cannot load such file -- openssl (LoadError)'

ruby - Jekyll/Ruby Kramdown 缺少依赖

ruby - 缩短 Ruby 中的 if-else 结构

ruby - Ruby 程序的结构

ruby - 为什么我不能传递一个 block 变量来注入(inject)?

web-deployment - 无法让 site.baseurl 在 jekyll 中工作

jekyll - 将数据文件复制到 Jekyll 项目中的 '_sites"

ruby-on-rails - Raphael 中的 SVG 文件,可以使用吗?