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

Closed
JonathanMatthey opened this Issue Feb 1, 2015 · 24 comments

Projects

None yet
@JonathanMatthey

Error details

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

    Permission denied @ dir_s_mkdir - ./.gem.20150131-61502-djrp3

Gem files will remain installed in /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/nokogiri-1.6.6.2/gem_make.out

    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tmpdir.rb:85:in `mkdir'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tmpdir.rb:85:in `block in mktmpdir'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tmpdir.rb:142:in `create'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tmpdir.rb:85:in `mktmpdir'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:14:in `build'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:161:in `block (2 levels) in build_extension'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `chdir'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `block in build_extension'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `synchronize'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `build_extension'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/vendor/net/http/persistent.rb:12:in `<top (required)>'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/vendored_persistent.rb:11:in `<top (required)>'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/fetcher.rb:1:in `<top (required)>'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/cli/install.rb:72:in `run'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/cli.rb:157:in `install'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/vendor/thor/command.rb:27:in `run'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/vendor/thor.rb:363:in `dispatch'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/vendor/thor/base.rb:440:in `start'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/cli.rb:10:in `start'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/bin/bundle:20:in `block in <top (required)>'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/lib/bundler/friendly_errors.rb:6:in `with_friendly_errors'
    /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.8.0.pre/bin/bundle:18:in `<top (required)>'
    /Users/ratciti/.rbenv/versions/2.1.2/bin/bundle:23:in `load'
    /Users/ratciti/.rbenv/versions/2.1.2/bin/bundle:23:in `<main>'

Environment

Bundler   1.8.0.pre
Rubygems  2.2.2
Ruby      2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin14.0]
Git       1.9.3 (Apple Git-50)
@supertopher

TLDR:

  • i do not believe this is an issue with bundler

this looks like a permissions error. Bundler expects that you have permission to write to the directory the error:
Permission denied @ dir_s_mkdir - ./.gem.20150131-61502-djrp3
as well as an error that came from mkdir both suggest incorrect permissions. If you are on OSX user this is probably due to the inappropriate use of sudo. OSX by convention doesn't use sudo for much of any CLI installation unless you are using Macports

if you are using brew try brew doctor for help. or uninstall and reinstall rbenv (including it's dependencies from ~/.gem && ~/.rbenv) the try reinstalling this.

also rbenv doesn't install bundler by default it is plausible that you are using system bundler to try and install nokogiri even though you are using rbenv's ruby.

if you run which bundler and the return value is not rbenv something something try this:

gem install bundler && rbenv rehash

@TimMoore
Member

I agree, this looks like filesystem permissions are set up incorrectly. Check permissions on your project directory and on /Users/ratciti/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.6.2 (I believe it changes to the gem directory before building) to make sure you can write files as the user that you're running Bundler with.

@TimMoore TimMoore closed this Feb 11, 2015
@willbowling

What resolved my issue was to install bundler without sudo. "gem install bundler".

@xicoofficial

Installing bundle "gem install bundler" also solved my similar issue

@sergio-ocon

I was using rbenv in Fedora and got the same message. I couldn't understand why.
At the end, it was a lack of underneath packages, it was solved installing them:
sudo dnf install ruby-devel cmake mariadb-devel rubygems-devel
bundler update
bundler install

@jclaret
jclaret commented Sep 29, 2015

it works for fedora 22 too.

thanks sergio-ocon!

@Viktorminator
gem install bundler

solved the problem

@kmcmcurtis7

Thanks for the info! I ran into this and this resolved the problem quickly.

@Abdull
Abdull commented Feb 19, 2016

sudo apt-get install ruby2.2-dev

@zoomwebstudio

This solution works perfectly for me. thanks to @Abdull
sudo apt-get install ruby2.2-dev
and after I ran
bundle install

@shrinivas91

I used sudo apt-get install ruby2.2-dev
But I'm getting the following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ruby2.2-dev
E: Couldn't find any package by regex 'ruby2.2-dev'

@dailsoncampos
dailsoncampos commented Apr 23, 2016 edited

My problem is this "Make sure that gem install debugger -v '1.6.8' succeeds before bundling". I've tried install it, but the problem continues...

@willbowling

Should probably run gem bundler install? If that is what you intend to use.
Ie "bundle exec" etc.

I also personally use rvm for my ruby versions. It seems more maintainable.
On Apr 22, 2016 10:50 PM, "Dailson Campos" notifications@github.com wrote:

My problem is this "Make sure that gem install debugger -v '1.6.8'
succeeds before bundling error". What can I do?

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#3372 (comment)

@dailsoncampos

I run "bundle install".

โžœ dailsoncampos git:(Production) โœ— bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types 2.99
Using arel 6.0.3
Using debug_inspector 0.0.2
Using bundler 1.11.2
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using columnize 0.9.0
Using concurrent-ruby 1.0.1
Using debugger-linecache 1.2.0
Using debugger-ruby_core_source 1.3.8
Using multi_json 1.11.2
Using sass 3.4.22
Using tilt 2.0.2
Using spring 1.6.4
Using sqlite3 1.3.11
Using rdoc 4.2.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.2
Using rack-test 0.6.3
Using mail 2.6.3
Using binding_of_caller 0.7.2
Using coffee-script 2.4.1
Using uglifier 2.7.2
Using sprockets 3.5.2
Installing debugger 1.6.8 with native extensions

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

/home/campos/.rvm/rubies/ruby-2.1.8/bin/ruby -r ./siteconf20160423-10896-9be59d.rb extconf.rb

*** 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=/home/campos/.rvm/rubies/ruby-2.1.8/bin/ruby
/home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:1401:in initialize': No such file or directory @ rb_sysopen - ./218/ruby_debug.h (Errno::ENOENT) from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:1401:inopen'
from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:1401:in copy_file' from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:483:incopy_file'
from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:400:in block in cp' from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:1579:inblock in fu_each_src_dest'
from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:1593:in fu_each_src_dest0' from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:1577:infu_each_src_dest'
from /home/campos/.rvm/rubies/ruby-2.1.8/lib/ruby/2.1.0/fileutils.rb:399:in cp' from extconf.rb:83:inblock in

'
from extconf.rb:82:in each' from extconf.rb:82:in'

extconf failed, exit code 1

Gem files will remain installed in /home/campos/.rvm/gems/ruby-2.1.8/gems/debugger-1.6.8 for inspection.
Results logged to /home/campos/.rvm/gems/ruby-2.1.8/extensions/x86_64-linux/2.1.0/debugger-1.6.8/gem_make.out
Using sdoc 0.4.1
Using activesupport 4.2.5.1
Using loofah 2.0.3
An error occurred while installing debugger (1.6.8), and Bundler cannot
continue.
Make sure that gem install debugger -v '1.6.8' succeeds before bundling.

@willbowling

Try 'gem bundler install'. Even though when you run the command, it's
'bundle exec'. Bundler === bundle. Hope that helps.
On Apr 22, 2016 11:18 PM, "Dailson Campos" notifications@github.com wrote:

I'm sorry. I'm beginner in ruby on rails...

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#3372 (comment)

@willbowling

At work we use the combo "bundle exec && bundle compass watch" or "bundle
exec && bundle guard watch"
On Apr 22, 2016 11:20 PM, "Will Bowling" will.bowling@weather.com wrote:

Try 'gem bundler install'. Even though when you run the command, it's
'bundle exec'. Bundler === bundle. Hope that helps.
On Apr 22, 2016 11:18 PM, "Dailson Campos" notifications@github.com
wrote:

I'm sorry. I'm beginner in ruby on rails...

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#3372 (comment)

@dailsoncampos

Man! Is there any problem if I comment the gem debugger? Cause I've commented and it's running...

@willbowling

Can't help there man. Sounds like a gem I don't use. Good luck!
On Apr 22, 2016 11:30 PM, "Dailson Campos" notifications@github.com wrote:

Man! Is there any problem if I comment the gem debugger? Cause I've
commented and it's running...

โ€”
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#3372 (comment)

@dailsoncampos

Thank you! I'm sorry my bad English ๐Ÿ˜„

@ArionHardison
ArionHardison commented Jul 13, 2016 edited

gem uninstall nokogiri
xcode-select --install
gem install nokogiri

Worked for me.

@vikrantgithub

error.txt
please help me

@supertopher

@vikrantgithub this isn't really the place for this kind of question exactly. given that this appears to be a heroku deployment you should ask that question in a heroku-related venue.

Bundler is working as intended for your use case and this is a place for bundler questions.

that said however, heroku doesn't support mysql. you will need to migrate to postrges or a database type that heroku does support. This article may be helpful to you good luck

@shabbir-ahmed

I run bundle install

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing
your bundle as root will break this application for all non-root users on this
machine.
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 12.0.0
Using concurrent-ruby 1.0.4
Using i18n 0.7.0
Using minitest 5.10.1
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using rack 2.0.1
Installing nio4r 1.2.1 with native extensions
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 7.1.4
Installing debug_inspector 0.0.2 with native extensions
Using bundler 1.13.7
Installing byebug 9.0.6 with native extensions
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.4
Using multi_json 1.12.1
Using json 1.8.3
Installing mysql2 0.4.5 with native extensions
Using rdoc 4.3.0
Using sass 3.4.23
Using tilt 2.0.5
Using turbolinks-source 5.0.0
Using tzinfo 1.2.2
Installing nokogiri 1.7.0.1 with native extensions
Using rack-test 0.6.3
Using sprockets 3.7.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r

/usr/bin/ruby2.3 -r ./siteconf20170109-3150-tw7km1.rb extconf.rb
--with-cflags=-std=c99
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/nio4r-1.2.1 for
inspection.
Results logged to
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-1.2.1/gem_make.out

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

I don't understanding what is it

@colby-swandale
Member

@shabbir-ahmed you're missing the required ruby headers to install the library. Look into installing ruby-dev or similar on your platform.

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