Termux-packages: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

Created on 27 Apr 2017  路  20Comments  路  Source: termux/termux-packages

$ cd git/sdrausty/sdrausty.github.io/
$ ./script/
bootstrap cibuild release server
$ ./script/bootstrap
Successfully installed bundler-1.14.6
1 gem installed
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using public_suffix 2.0.5
Using colorator 1.1.0
Installing ffi 1.9.18 with native extensions
Using forwardable-extended 2.6.0
Using sass 3.4.23
Using rb-fsevent 0.9.8
Using kramdown 1.13.2
Using liquid 3.0.6
Using mercenary 0.3.6
Using rouge 1.11.1
Using safe_yaml 1.0.4
Using bundler 1.14.6
Using addressable 2.5.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/ext/ffi_c
/data/data/com.termux/files/usr/bin/ruby -r ./siteconf20170427-30050-kaueq1.rb
extconf.rb
mkmf.rb can't find header files for ruby at
/data/data/com.termux/files/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in
/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/gems/ffi-1.9.18 for
inspection.
Results logged to
/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/extensions/arm-linux/2.4.0/ffi-1.9.18/gem_make.out

An error occurred while installing ffi (1.9.18), and Bundler cannot
continue.
Make sure that gem install ffi -v '1.9.18' succeeds before bundling.

question ruby

Most helpful comment

apt install ruby-dev libffi-dev
Termux uses packaging layout similar to Ubuntu, i.e. development related files in a separate package.

All 20 comments

$ cat ./script/bootstrap

!/data/data/com.termux/files/usr/bin/sh

set -e

gem install bundler
bundle install

$ l /data/data/com.termux/files/usr/lib/ruby/include/ruby.h
ls: cannot access '/data/data/com.termux/files/usr/lib/ruby/include/ruby.h': No such file or directory

Where is ruby.h? Does anyone know?

apt install ruby-dev libffi-dev
Termux uses packaging layout similar to Ubuntu, i.e. development related files in a separate package.

Been there'n'done dat, still no rubby.h on my device.

ruby/stable,now 2.4.1-1 arm [installed]
ruby-dev/stable,now 2.4.1-1 arm [installed]
ruby-ri/stable,now 2.4.1-1 all [installed]

Do you have ruby.h on device?

libffi/stable,now 3.2.1-2 arm [installed,automatic]
libffi-dev/stable,now 3.2.1-2 arm [installed]

Just noticed that the path is wrong. /data/data/com.termux/files/usr/lib/ruby/include/ruby.h

It should be /data/data/com.termux/files/usr/include/ruby-2.4.0/ruby.h
I can gem install ffi -v '1.9.18' just fine.

$ dpkg --search ruby.h ruby-dev: /data/data/com.termux/files/usr/include/ruby-2.4.0/ruby.h ruby-dev: /data/data/com.termux/files/usr/include/ruby-2.4.0/ruby/ruby.h

find -name ruby.h
./files/usr/include/ruby-2.4.0/ruby/ruby.h
./files/usr/include/ruby-2.4.0/ruby.h

But still:
An error occurred while installing ffi (1.9.18), and
Bundler cannot continue.
Make sure that gem install ffi -v '1.9.18' succeeds before
bundling.

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/ext/ffi_c
/data/data/com.termux/files/usr/bin/ruby -r
./siteconf20170427-2798-ub4d47.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}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/data/data/com.termux/files/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}/lib
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:457:in
try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:588:in try_cpp'
from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:1095:in
block in have_header' from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:945:in block in checking_for'
from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:351:in
block (2 levels) in postpone' from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:321:in open'
from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:351:in
block in postpone' from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:321:in open'
from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:347:in
postpone' from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:944:in checking_for'
from /data/data/com.termux/files/usr/lib/ruby/2.4.0/mkmf.rb:1094:in
have_header' from extconf.rb:16:in

'

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

/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/extensions/arm-linux/2.4.0/ffi-1.9.18/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/gems/ffi-1.9.18
for inspection.
Results logged to
/data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/extensions/arm-linux/2.4.0/ffi-1.9.18/gem_make.out

An error occurred while installing ffi (1.9.18), and
Bundler cannot continue.
Make sure that gem install ffi -v '1.9.18' succeeds before
bundling.

ln -s /data/data/com.termux/files/usr/include/ruby-2.4.0/ruby.h /data/data/com.termux/files/usr/lib/ruby/include/ruby.h

Doesn't help either; Any suggestions?

$ gem install ffi -v '1.9.18'
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.

current directory: /data/data/com.termux/files/usr/lib/ruby/gems/2.4.0/gems/ffi-1.9.18/ext/ffi_c

/data/data/com.termux/files/usr/bin/ruby -r ./siteconf20170427-6745-19bahy2.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.

I revisited this issue, but on aarch64 not arm architecture as in the previous posts. Also this installation is fairly complete apt install * almost worked out of the box.

gem install bundler and the subsequent local build of website work on aarch64.

I'm still seeing this bug when using an intel m3 powered chromebook. (asus c302ca flip)

There were two reasons why I closed this issue:

  1. I switched architectures;
  2. I was under the impression once gem install bundler works, that it would exclusively work locally. It doesn't. It contacts a website for rebuilds.

Please feal free to reopen this issue if you need to.

use sudo apt-get install ruby-dev

@vivekanand-pst That's a bad suggestion as using apt as root breaks stuff.

apt install ruby-dev works fine

@vivekanand-pst Also we don't have command sudo, but tsudo from tsu package.

In my case, I enabled a SWAP file (in amazon server 1GB RAM) and this error does not show again.

$ sudo dd if=/dev/zero of=/swapfile bs=1M count=2000
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

test with:
$ swapon -s
$ free -h

reference to create swapfile.
https://aws.amazon.com/pt/premiumsupport/knowledge-center/ec2-memory-swap-file/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zuccace picture Zuccace  路  3Comments

neitsab picture neitsab  路  3Comments

Cyb3rD3m0n picture Cyb3rD3m0n  路  3Comments

roalyr picture roalyr  路  3Comments

Wetitpig picture Wetitpig  路  3Comments