Install gem gives "Failed to build gem native extension." - ruby

I did: sudo apt-get install ruby ruby-dev.
And i run: sudo gem install jekyll.
But it gives this output:
Building native extensions. This could take a while... ERROR: Error
installing jekyll: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 -r ./siteconf20151018-15792-1gfjwox.rb extconf.rb creating Makefile
make "DESTDIR=" clean sh: 1: make: not found
make "DESTDIR=" sh: 1: make: not found
make failed, exit code 127
Gem files will remain installed in
/var/lib/gems/2.1.0/gems/fast-stemmer-1.0.2 for inspection. Results
logged to
/var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/fast-stemmer-1.0.2/gem_make.out

You need to install make and other build tools first, run this:
sudo apt-get install build-essential

make: not found
This means that the program make (that is used to build libraries from code) is not present on your machine. You should try to install it with your package manager.
sudo apt-get cmake
might do the trick.

sudo apt-get install build-essential solves the issue for mysql gem failing due to make program failure for linux.

Related

How do I fix an error with Ruby Gems Installer on WSL?

I tried to install a package using RubyGems (please note that I use Windows Subsystem for Linux). I was going to install Jekyll package.
I typed $ gem install jekyll. After that it came up with an error:
Building native extensions. This could take a while...
/usr/lib/ruby/2.5.0/rubygems/ext/builder.rb:76: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
Can you please explain the error and any possible ways to fix it?
You need to install the build tools needed:
sudo apt-get update
sudo apt-get install build-essential
I had to install ruby-full to get this working on WSL:
sudo apt install ruby-full

Unable to install json 1.8.3 in ruby 2.2.1

I am running bundle install in Ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] (installed with rvm 1.25.33) and bundler 1.10.6
When it tries to install json 1.8.3, I get the following:
Installing json 1.8.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/andrew/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150905-31357-cgs3dn.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
linking shared-object json/ext/generator.so
make "DESTDIR=" install
./install -m 0755 generator.so ./.gem.20150905-31357-199esvy/json/ext
make: ./install: Command not found
make: *** [install-so] Error 127
make install failed, exit code 2
On the same host, I am able to install json 1.8.3 in ruby 2.1.3.
In another SO question I see the suggestion to make sure that install is available. I get valid output when I do install --help.
What should I do? Why is the gem able to install in 2.1.3 and not 2.2.1?
simple fix delete your gem.lock file and run bundle install this should rebuild the gemlock file and fix the issue, i was getting the same error when trying to move my development environment from nitrous.io to cloud9,. hope this help
copy from migs120's answer https://github.com/flori/json/issues/253
I use macOS sierra, it's work fine.
I would suggest try this for MacOS,
bundle update json --conservative
It will resolve the error.
Install the following package in ubuntu
sudo apt-get install libgmp3-dev
For more information
https://github.com/flori/json/issues/253
In OSX, do the following
brew install coreutils

json gem install error on bundle install

When I try to do a bundle install I get the following json error. The bundle install does not complete. What gives?
Errno::EACCES: Permission denied - /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.7.5/.gitignore
An error occurred while installing json (1.7.5), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.5'` succeeds before bundling.
>>$ gem install json -v '1.7.5'
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.7.5/.gitignore
EDIT: The sudo install command gives the following error:
>>$ sudo gem install json -v '1.7.5'
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/usr/local/Cellar/ruby/1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
sh: make: command not found
Gem files will remain installed in /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.7.5 for inspection.
Results logged to /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
you need to install ruby1.8-dev and not just ruby1.8, you are missing the development headers.
if on OSX:
sudo install ruby1.8-dev
if on unix
sudo aptitude install ruby1.8-dev
or
sudo apt-get install ruby1.8-dev
go into your directory with rubygems source and run:
sudo ruby setup.rb
after that run:
if on OSX:
sudo gem install json -v '1.7.5'
some unix system may need gem version command to work properly so you should run:
sudo gem1.8 install json -v '1.7.5'
Try using this script
sudo chown -R $USER /usr/local
Found the answer here: "sh: make: command not found" when running "$ bundle" after adding redcarpet gem to Rails app Needed to upgrade command line tools after installing Mountain Lion

gem install memcached fails

On doing
gem install memcached
following error gets thrown.
....
....
checking for pod2man... /usr/bin/pod2man
./configure: line 22468: syntax error near unexpected token `sasl,,'
./configure: line 22468: ` AC_LIB_HAVE_LINKFLAGS(sasl,,'
make: *** [config.status] Error 2
*** 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.
I have already install libmemcached using
sudo yum install libmemcached
On Ubuntu, try doing:
sudo apt-get install libsasl2
sudo apt-get install libsasl2-dev
I encountered this issue trying to install the memcached gem on Amazon's AMI Linux.
I resolved it with installing both cyrus-sasl and cyrus-sasl-devel:
cyrus-sasl.i686 : The Cyrus SASL library
cyrus-sasl-devel.i686 : Files needed for developing applications with Cyrus SASL
as well as, and this is key:
gettext.i686 : GNU libraries and utilities for producing multi-lingual messages
gettext-devel.i686 : Development files for gettext
Once these were installed
sudo gem install memcached
Building native extensions. This could take a while...
Successfully installed memcached-1.3.5
1 gem installed
I think you need to install memcache-client instead.
gem install memcache-client
and you will see this:
1 gem installed
Installing ri documentation for memcache-client-1.8.5...
Installing RDoc documentation for memcache-client-1.8.5...

Can't install ruby-ldap under Windows/Cygwin

gem install ruby-ldap
Building native extensions. This could take a while...
ERROR: Error installing ruby-ldap:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
--with-ldap-dir=/usr
--with-openldap2
checking for ldap.h... yes
[...]
creating Makefile
make
gcc -I. -I. -I/usr/lib/ruby/1.8/i386-cygwin -I. ...
[...]
gcc -shared -s -o ldap.so ...
The configuration and the compilation works just fine. But the installation throws this error:
make install
/usr/bin/install -c -m 0755 ldap.so /usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib
/usr/bin/install -c -m 644 ./lib/ldap/control.rb /usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap
/usr/bin/install: `./lib/ldap/control.rb' and `/usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb' are the same file
Makefile:130: recipe for target `/usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb' failed
make: *** [/usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb] Error 1
./lib/ldap/control.rb and /usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb are indeed the same file, but why? Other gems with nativ bindings like mysql worked just fine. I reported this as a bug, but some other guy does not have the problem, so the package itself is intact.
If I download the gem and run:
ruby extconf.rb
make install
The Makefile runs just fine.
It must be my system/configuration. Whats going wrong here?
Wow, very oddly, I got this working by downgrading RubyGems and then upgrading it back. I downgraded it first to match a version (1.4.1) I had on another system that could install ruby-ldap just fine. I thought this might make it work on my current system, but I got the same error you did. I upgraded RubyGems back to what I had (1.8.15), then it all magically worked.
So:
$ gem update --system 1.4.1 # Downgrade to 1.4.1
...
$ gem update --system # Go back to current
...
$ gem install ruby-ldap
Building native extensions. This could take a while...
Successfully installed ruby-ldap-0.9.12
1 gem installed
Installing ri documentation for ruby-ldap-0.9.12...
Installing RDoc documentation for ruby-ldap-0.9.12...
$
FYI, I didn't have to use sudo because I'm using rvm and I was installing ruby-ldap into a per-project gemset.
If you are using Ubunty, try to perform
sudo apt-get install libsasl2-dev
More about it at https://github.com/alexey-chebotar/ruby-ldap/issues/7

Resources