Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem install fails: ERROR: Failed to build gem native extension #558

Closed
Blockost opened this issue Nov 20, 2017 · 13 comments
Closed

gem install fails: ERROR: Failed to build gem native extension #558

Blockost opened this issue Nov 20, 2017 · 13 comments

Comments

@Blockost
Copy link

Hi guys,

Travis CLI does not seem to be willing to install on my machine (I'm using this docker image as my container).

root@ff8ac5453dbc:~# gem install travis
Building native extensions. This could take a while...
ERROR:  Error installing travis:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby2.3 -r ./siteconf20171120-16712-g2o2td.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=/usr/bin/$(RUBY_BASE_NAME)2.3
        --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
/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 /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
        from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
        from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
        from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
        from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
        from extconf.rb:16:in `<main>'

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

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/ffi-1.9.18/mkmf.log

extconf failed, exit code 1

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

I'm using Gem 2.7.2 and ruby 2.3.3

root@ff8ac5453dbc:~# gem -v
2.7.2
root@ff8ac5453dbc:~# ruby -v
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

Also, ruby dev kit is already installed:

root@ff8ac5453dbc:~#  apt-get install ruby-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
ruby-dev is already the newest version (1:2.3.3).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Has anyone encoutered the same problem ? I need Travis CLI to encrypt my api_key for deployment.

Thanks,
Simon.

@dante-signal31
Copy link

I had the same problem than you. I was in a clean Ubuntu box.

In the end I was able to build travis-cli after installing these dependencies:

  • ruby-dev
  • gcc
  • libffi-dev
  • make

Regards,

Dante

@rob137
Copy link

rob137 commented Jan 9, 2018

Dante,

I'm in the same fix - just tried installing those dependencies. I downloaded make without any problems, but 'sudo gem install [dependency]' didn't work for ruby-dev, gcc or libffi-dev:
ERROR: Could not find a valid gem '[dependency]' (>= 0) in any repository

Any idea what I'm doing wrong?

@dante-signal31
Copy link

What is happenning is that those are system dependencies not Ruby dependencies.

Try to install them using your system package manager (apt-get in debian).

By the way, be aware that I gave you the names those packages have in Ubuntu, they may have different names in other distributions.

@michael-pratt
Copy link

I was having this issue on MacOS Mojave. Installing latest ruby via Homebrew and setting some env variables solved it for me:

export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

@nelson6e65
Copy link

In Fedora (29, x64), I had to install all dev tools:

sudo dnf install @development-tools
sudo dnf install @rpm-development-tools # missing

@BanzaiMan
Copy link
Contributor

Closing in favor of #758. It no longer depends on native extensions, so the installation should be easier. If the issue persists, feel free to open a new one.

@iadeelzafar
Copy link

I was having the same issue today when installing fastlane. Fixed it by following @dante-signal31 's advice. Additonally, I also had to add sudo apt-get install build-essential g++

@JaminZhou
Copy link

If you are using a mac, you can try it.

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. xcode-select --install
  3. sudo xcodebuild -license accept
  4. open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

@ferreroxc
Copy link

I had the same problem than you. I was in a clean Ubuntu box.

In the end I was able to build travis-cli after installing these dependencies:

  • ruby-dev
  • gcc
  • libffi-dev
  • make

Regards,

Dante

Thanks!! And also need g++ in my case.

@Prasad-03
Copy link

I am facing same problem for windows10, can anybody got solution for windows.
My ruby version is 3.0.3p157 and rails is 6.1.4.1.
I upgrade my ruby version from 2.6.9 to latest one and try to bundle install and got this error.

@tqmMohit
Copy link

If you are using a mac, you can try it.

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. xcode-select --install
  3. sudo xcodebuild -license accept
  4. open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Works for me thanks.

@vuboi
Copy link

vuboi commented May 26, 2023

sudo apt-get install build-essential g++

+1 worked for me thanks

perfect. thank you

@yoyo115956
Copy link

I was having the same issue today when installing fastlane. Fixed it by following @dante-signal31 's advice. Additonally, I also had to add sudo apt-get install build-essential g++

This really helped me, I switched from windows to Ubuntu on wsl, and your solution effectively solved my problem, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

14 participants