An error occurred while installing nio4r (2.1.0), and Bundler cannot continue. (Ubuntu) #159

Closed
aruprakshit opened this Issue Jul 17, 2017 · 15 comments

Comments

Projects
None yet
6 participants

My System is ubuntu

deploy@ip-172-31-32-223:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

When I do bundle exec mina deploy, got error as below:

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

       current directory:
       /home/deploy/app/shared/vendor/bundle/ruby/2.4.0/gems/nio4r-2.1.0/ext/nio4r
       /usr/bin/ruby2.4 -r ./siteconf20170717-22076-k9m8q5.rb extconf.rb
       --with-cflags=-std=c99
       checking for unistd.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=/usr/bin/$(RUBY_BASE_NAME)2.4
       /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 /usr/lib/ruby/2.4.0/mkmf.rb:588:in `try_cpp'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:1095:in `block in have_header'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:945:in `block in checking_for'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:351:in `block (2 levels) in postpone'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:321:in `open'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:351:in `block in postpone'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:321:in `open'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:347:in `postpone'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:944:in `checking_for'
       	from /usr/lib/ruby/2.4.0/mkmf.rb:1094:in `have_header'
       	from extconf.rb:5:in `<main>'

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

       /home/deploy/app/tmp/build-15002732108911/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/nio4r-2.1.0/mkmf.log

       extconf failed, exit code 1

       Gem files will remain installed in
       /home/deploy/app/tmp/build-15002732108911/vendor/bundle/ruby/2.4.0/gems/nio4r-2.1.0
       for inspection.
       Results logged to
       /home/deploy/app/tmp/build-15002732108911/vendor/bundle/ruby/2.4.0/extensions/x86_64-linux/2.4.0/nio4r-2.1.0/gem_make.out

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

       In Gemfile:
         rails was resolved to 5.0.4, which depends on
           actioncable was resolved to 5.0.4, which depends on
             nio4r
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK
 !     Run Error

I tried sudo apt-get install ruby-dev zlib1g-dev liblzma-dev from link, but no luck. How can I fix this?

Contributor

tarcieri commented Jul 17, 2017

@tarcieri My ruby is installed following this post . Do you think it is something related to the Ruby installation?

Contributor

tarcieri commented Jul 17, 2017

Please check the mkmf.log file for the error

@tarcieri tarcieri closed this Jul 17, 2017

@tarcieri Was that quick close was required?

Contributor

tarcieri commented Jul 17, 2017

This is almost certainly not an issue with nio4r but one in your Ruby environment, so yes.

aruprakshit commented Jul 17, 2017

@tarcieri Ok fine. I think the gem lacks good documentation. It should mention required packages it needs to get compiled. If I look at the internet, many people faced it when upgraded to Rails 5. It will be good to have a documentation like this.

Contributor

tarcieri commented Jul 17, 2017

Sorry, it is not me. It is many people faced it. You can see -> link.

Contributor

tarcieri commented Jul 17, 2017

I had same error. In my case it was because nio4r required libgmp3-dev package.
So:
sudo apt-get install libgmp3-dev
fixed the problem.

Contributor

tarcieri commented Aug 23, 2017

@swarzynski nio4r absolutely does NOT have any dependency on libgmp3, it is entirely self-contained and only depends on a C compiler.

Installing libgmp3 likely fixed compilation of a completely different native dependency in your app, not nio4r

@swarzynski I suspect that when you installed libgmp3-dev, apt also installed ruby-dev as a dependency. I was getting the same nio4r problem as you until I installed ruby-dev - the problem was that the ruby headers were missing.

oquidave commented Oct 3, 2017

@swarzynski solution of installing ruby-dev worked for me

ehalferty commented Oct 30, 2017

Same here. The ruby-dev package is now required to install the rails 5 gem on ubuntu, it seems.

Contributor

tarcieri commented Oct 30, 2017

Yes, Rails 5 includes several native extensions, one of which is this gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment