Termux-packages: Nokogiri gem refuses to install

Created on 15 Aug 2016  路  14Comments  路  Source: termux/termux-packages

Thank you for this awesome app!!!

My objective is to install Rails in Termux but when it reach to the point of installing Nokogiri this is what I get:

$ gem install nokogiri -- --use-system-libraries
Fetching: mini_portile2-2.1.0.gem (100%)
Successfully installed mini_portile2-2.1.0
Fetching: pkg-config-1.1.7.gem (100%)
Successfully installed pkg-config-1.1.7
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

    current directory: /data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/data/data/com.termux/files/usr/bin/ruby -r ./siteconf20160814-25952-xnoji1.rb extconf.rb --use-system-libraries
Using pkg-config version 1.1.7
checking if the C compiler accepts ... *** 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)
        --help
        --clean
/data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:456: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.3.0/mkmf.rb:571:in `block in try_compile'
        from /data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:522:in `with_werror'
from /data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:629:in `with_cflags'
        from extconf.rb:161:in `add_cflags'
        from extconf.rb:414:in `<main>'

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.3.0/extensions/arm-linux/2.3.0/nokogiri-1.6.8/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8 for inspection.
Results logged to /data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/extensions/arm-linux/2.3.0/nokogiri-1.6.8/gem_make.out
bug report ruby

Most helpful comment

Have you installed the required packages?

apt install ruby-dev libxml2-dev libxslt-dev pkg-config make clang

Could you also try with running gem cleanup first? If the problem remains, can you attach the contents of

/data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/extensions/arm-linux/2.3.0/nokogiri-1.6.8/mkmf.log

here?

All 14 comments

Thanks, this was a regression after the recent gcc-to-clang transition, but has now been fixed int he latest clang package (version 3.8.1-2) - update to it with apt update && apt upgrade and try again!

I just did the upgrade of the clang package with apt update && apt upgrade, then I ran the gem install nokogiri -- --use-system-libraries but I still get the error:

$ gem install nokogiri -- --use-system-libraries
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

    current directory: /data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/gems/nokogiri-1.6.8/ext/nokogiri
/data/data/com.termux/files/usr/bin/ruby -r ./siteconf20160816-2216-jfsmt1.rb extconf.rb --use-system-libraries
Using pkg-config version 1.1.7
checking if the C compiler accepts ... *** 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)

--without-make-prog
        --srcdir=.
        --curdir
        --ruby=/data/data/com.termux/files/usr/bin/$(RUBY_BASE_NAME)
        --help
        --clean
/data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:456: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.3.0/mkmf.rb:571:in `block in try_compile'
        from /data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:522:in `with_werror'
        from /data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
        from extconf.rb:138:in `nokogiri_try_compile'
        from extconf.rb:162:in `block in add_cflags'
        from /data/data/com.termux/files/usr/lib/ruby/2.3.0/mkmf.rb:629:in `with_cflags'
        from extconf.rb:161:in `add_cflags'
        from extconf.rb:414:in `<main>'

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.3.0/extensions/arm-linux/2.3.0/nokogiri-1.6.8/mkmf.log

extconf failed, exit code 1

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

Have you installed the required packages?

apt install ruby-dev libxml2-dev libxslt-dev pkg-config make clang

Could you also try with running gem cleanup first? If the problem remains, can you attach the contents of

/data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/extensions/arm-linux/2.3.0/nokogiri-1.6.8/mkmf.log

here?

Also, check that you have the updated clang package:

apt-cache show clang | grep Version

should output

Version: 3.8.1-2

yeah! it works! thanks @fornwall!!!!

Hi. Didnt want to open a new issue, but I am having the same problem with nokogiri 1.7.0.1.

Any ideas? The output of

less /data/data/com.termux/files/usr/lib/ruby/gems/2.3.0/extensions/arm-linux/2.3.0/nokogiri-1.7.0.1/mkmf.log

is:

"gcc -o conftest -I/data/data/com.termux/files/usr/include/ruby-2.3.0/arm-linux-androideabi -I/data/data/com.termux/files/usr/include/ruby-2.3.0/ruby/backward -I/data/data/com.termux/files/usr/include/ruby-2.3.0 -I. -I/data/data/com.termux/files/usr/include -isystem /data/data/com.termux/files/usr/include/libandroid-support    -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Os -fPIC  conftest.c  -L. -L/data/data/com.termux/files/usr/lib -L.  -L/data/data/com.termux/files/usr/lib -march=armv7-a -Wl,--fix-cortex-a8 -landroid-support -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby  -lgmp -ldl -lm   -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"gcc -I/data/data/com.termux/files/usr/include/ruby-2.3.0/arm-linux-androideabi -I/data/data/com.termux/files/usr/include/ruby-2.3.0/ruby/backward -I/data/data/com.termux/files/usr/include/ruby-2.3.0 -I. -I/data/data/com.termux/files/usr/include -isystem /data/data/com.termux/files/usr/include/libandroid-support    -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Os -fPIC    -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main() {return 0;}
/* end */

have_library: checking for gzdopen() in -lz... -------------------- yes

"gcc -o conftest -I/data/data/com.termux/files/usr/include/ruby-2.3.0/arm-linux-androideabi -I/data/data/com.termux/files/usr/include/ruby-2.3.0/ruby/backward -I/data/data/com.termux/files/usr/include/ruby-2.3.0 -I. -I/data/data/com.termux/files/usr/include -isystem /data/data/com.termux/files/usr/include/libandroid-support    -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Os -fPIC  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/data/data/com.termux/files/usr/lib -L.  -L/data/data/com.termux/files/usr/lib -march=armv7-a -Wl,--fix-cortex-a8 -landroid-support -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby -lz  -lgmp -ldl -lm   -lc "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <zlib.h>
 4: 
 5: /*top*/
 6: extern int t(void);
 7: int main(int argc, char **argv)
 8: {
 9:   if (argc > 1000000) {
10:     printf("%p", &t);
11:   }
12: 
13:   return 0;
14: }
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))gzdopen; return !p; }
/* end */

--------------------

have_iconv?: checking for iconv... -------------------- yes

"gcc -o conftest -I/data/data/com.termux/files/usr/include/ruby-2.3.0/arm-linux-androideabi -I/data/data/com.termux/files/usr/include/ruby-2.3.0/ruby/backward -I/data/data/com.termux/files/usr/include/ruby-2.3.0 -I. -I/data/data/com.termux/files/usr/include -isystem /data/data/com.termux/files/usr/include/libandroid-support    -march=armv7-a -mfpu=neon -mfloat-abi=softfp -Os -fPIC  -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline conftest.c  -L. -L/data/data/com.termux/files/usr/lib -L.  -L/data/data/com.termux/files/usr/lib -march=armv7-a -Wl,--fix-cortex-a8 -landroid-support -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby  -lgmp -ldl -lm   -lc "
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <stdlib.h>
 4: #include <iconv.h>
 5: 
 6: int main(void)
 7: {
 8:     iconv_t cd = iconv_open("", "");
 9:     iconv(cd, NULL, NULL, NULL, NULL);
10:     return EXIT_SUCCESS;
11: }
/* end */

--------------------

Thanks!

@SpriteMidr Have you installed dependencies with:

apt install ruby-dev libxslt-dev pkg-config make clang

, run gem cleanup to ensure a clean build and then try to install nokogiri with:

gem install nokogiri -- --use-system-libraries

If so, do you get the

ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

message?

  1. [x] Installed Dependancies
  2. [x] gem cleanup
  3. [x] -- --use-system-libraries

I tried purging gem with
apt purge ruby ruby-dev -y && apt install ruby ruby-dev -y
and then tried step 3 again and it works!

Thank you very much for the help! Why do we need to
-- --use-system-libraries?

Just curious as to what caused the issue.

Thank you for helping me so quickly! It is much appreciated.

Edit: TIL GH wont support MD in email replies...

Thank you very much for the help! Why do we need to
-- --use-system-libraries?

If -use-system-libraries is not specified, nokogiri tries building bundled versions of the libraries, and this does not work due to the build process assuming that /bin/sh exists (which while generally a valid assumption, is not true on Android).

I know it isnt to do with you guys (I dont think)... but it is a shame it doesnt also check /system/bin for sh, as (at least on my unrooted S5 w/ android 6.0.1) this has a sh executable.

Would it be difficult to develop a virtual file system with a root directory for termux to use where everything is in /bin /usr/bin, etc like on an Ubuntu or Fedora system, and then have a mount point or something that allows you to cd into the main android root file system? Or does such a thing exist?

Sorry about the questions. I am just interested in how this works. Thanks for the quick reply.


Regards,

Ashley Jason Scopes (CMP)

(Sent from my S5)


From: Fredrik Fornwall notifications@github.com
Sent: Tuesday, January 10, 2017 12:01:38 PM
To: termux/termux-packages
Cc: Ashley Scopes (CMP); Mention
Subject: Re: [termux/termux-packages] Nokogiri gem refuses to install (#397)

Thank you very much for the help! Why do we need to
-- --use-system-libraries?

If -use-system-libraries is not specified, nokogiri tries building bundled versions of the libraries, and this does not work due to the build process assuming that /bin/sh exists (which while generally a valid assumption, is not true on Android).

-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/termux/termux-packages/issues/397#issuecomment-271558353, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AOMjBv3GvkuRMktVih0LDwjfHx-62tL3ks5rQ3MigaJpZM4JkCv4.

@SpriteMidr termux-chroot is available for this purpose. Install proot package to get it.
termux-chroot drops you into a proot evironment with standard mountpoints. Its really handy for development purposes.

I was not aware of this. This is awesome!

Thanks a bunch! Sorry if I caused any hassle :-)


Regards,

Ashley Jason Scopes (CMP)

(Sent from my S5)


From: Vishal Biswas notifications@github.com
Sent: Tuesday, January 10, 2017 3:27:09 PM
To: termux/termux-packages
Cc: Ashley Scopes (CMP); Mention
Subject: Re: [termux/termux-packages] Nokogiri gem refuses to install (#397)

@SpriteMidrhttps://github.com/SpriteMidr termux-chroot is available for this purpose. Install proot package to get it.
termux-chroot drops you into a proot evironment with standard mountpoints. Its really handy for development purposes.

-
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/termux/termux-packages/issues/397#issuecomment-271604862, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AOMjBj9w73I2zky4vFHAHv-GTbQK-eeFks5rQ6NNgaJpZM4JkCv4.

JFYI: I could install it with:
gem install nokogiri -- --use-system-libraries --with-xml2-config=/data/data/com.termux/files/usr/bin/xml2-config --with-xml2-include=/data/data/com.termux/files/usr/include/libxml2

gem install nokogiri -- --use-system-libraries not working.

`$ gem install nokogiri -- --use-system-libraries
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.

current directory: /data/data/com.termux/files/usr/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.4/ext/nokogiri

/data/data/com.termux/files/usr/bin/ruby -r ./siteconf20180801-19990-qeeuh.rb extconf.rb --use-system-libraries
checking if the C compiler accepts ... no
Building nokogiri using system libraries.
pkg-config could not be used to find libxml-2.0
Please install either pkg-config or the pkg-config gem per

gem install pkg-config -v "~> 1.1"

pkg-config could not be used to find libxslt
Please install either pkg-config or the pkg-config gem per

gem install pkg-config -v "~> 1.1"

pkg-config could not be used to find libexslt
Please install either pkg-config or the pkg-config gem per

gem install pkg-config -v "~> 1.1"

ERROR: cannot discover where libxml2 is located on your system. please make sure pkg-config is installed.
* 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)
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-libxslt-config
--without-libxslt-config
--with-exslt-dir
--without-exslt-dir
--with-exslt-include
--without-exslt-include=${exslt-dir}/include
--with-exslt-lib
--without-exslt-lib=${exslt-dir}/lib
--with-libexslt-config
--without-libexslt-config

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.5.0/extensions/arm-linux/2.5.0/nokogiri-1.8.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /data/data/com.termux/files/usr/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.4 for inspection.
Results logged to /data/data/com.termux/files/usr/lib/ruby/gems/2.5.0/extensions/arm-linux/2.5.0/nokogiri-1.8.4/gem_make.out
$`

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adit picture adit  路  3Comments

zejji picture zejji  路  4Comments

jackbrycesmith picture jackbrycesmith  路  3Comments

roycebank picture roycebank  路  3Comments

reggi picture reggi  路  4Comments