When I run the gem install mysql2 command I get the following error message:
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
...
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.
...
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/lucivaldo/.rvm/gems/ruby-2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.9/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/lucivaldo/.rvm/gems/ruby-2.4.0/gems/mysql2-0.4.9 for inspection.
Results logged to /home/lucivaldo/.rvm/gems/ruby-2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.9/gem_make.out
Looking at the log file described at the end of the message I noticed that some library is missing.
How to solve this problem?
Try to install client libraries:
sudo apt-get install ruby-mysql libmysqlclient-dev
Searching here in Stack Overflow itself, I found a solution to another problem similar to the following command, which also solves this problem:
sudo apt install libgmp3-dev
Related
I'm trying to install Ruby (3.2.0) (and Rails [7.0.4]) on an Intel Mac (OS 12.6). I'm running into issues with sqlite3 — no surprise. My current error message is this:
package configuration for /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-apple-darwin21.6.0/sqlite3/3.40.0/lib/pkgconfig/sqlite3.pc is not found
When I enter gem install sqlite3 I get the following ugly error message:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ext/sqlite3
/usr/local/opt/ruby/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.2.0 extconf.rb
Building sqlite3-ruby using packaged sqlite3.
Extracting sqlite-autoconf-3400000.tar.gz into tmp/x86_64-apple-darwin21.6.0/ports/sqlite3/3.40.0... OK
Running 'configure' for sqlite3 3.40.0... OK
Running 'compile' for sqlite3 3.40.0... OK
Running 'install' for sqlite3 3.40.0... OK
Activating sqlite3 3.40.0 (from /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-apple-darwin21.6.0/sqlite3/3.40.0)...
Could not configure the build properly (pkg_config). Please install either the `pkg-config` utility or the `pkg-config` rubygem.
*** 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:
[insert long list of options...]
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sqlite3-1.5.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sqlite3-1.5.4/gem_make.out
I've been through many iterations of solutions found across the interwebs (changing permissions, installing pkg-config per the error message, changing $PATH in .zshrc, installing sqlite binary packages, modifying the Gemfile, total uninstalls of both, and restarts) to no avail.
The Homebrew-installed sqlite3 is working properly. which sqlite3 produces
/usr/local/opt/sqlite3/bin/sqlite3
Happy to provide any more relevant information that's helpful. Any guidance appreciated!
If you do not have pkg-config installed, you should install to proceed
You can check it using:
$ which pkg-config
If not found, install it:
$ curl https://pkg-config.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkgconfig.tgz
$ tar -zxf pkgconfig.tgz && cd pkg-config-0.28
$ ./configure && make install
I'm just following this page
I am trying to update psych to 5.0.0, but I get the following error message:
Updating psych
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing psych:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/psych-5.0.0/ext/psych
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 extconf.rb
checking for yaml.h... no
yaml.h not found
*** 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:
.
.
.
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/psych-5.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/psych-5.0.0 for inspection.
Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/psych-5.0.0/gem_make.out
Tried gem update, gem pristine --all, same error.
Any tips how to fix this in Windows?
Thank you!
Not sure how it was fixed but I ran gem update and psych was updated to 5.0.2 without an error.
I had a similar problem on Mac running OSX 13.2. Bundle install failed because it couldn't find yaml.h.
Since I was on Mac and running Homebrew, I did a
brew install libyaml
and then re-ran bundle install. It worked correctly.
You need to install libyaml via pacman -S mingw-w64-ucrt-x86_64-libyamlin the command prompt with ruby
I'm currently having this problem when i try to install Rubocop(I can't install nokigiri either):
~$ sudo gem install rubocop
Building native extensions. This could take a while...
ERROR: Error installing rubocop:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
/usr/bin/ruby2.5 -r ./siteconf20190320-24856-1cn9xqz.rb extconf.rb
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.5.0/gems/jaro_winkler-1.5.2 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/jaro_winkler-1.5.2/gem_make.out
I've tried others solutions, but none worked.
Anyone knows why i'm getting this error ?
Thx
You need to install development headers for ruby 2.5, you don't have a development environment installed:
sudo apt-get install ruby2.5-dev
May also be called -devel depending on your packaging system.
I'm trying to install packetgen, a library for crafting and manipulating network packets. I followed all the instructions, and installed all the necessary libraries. However, when I ran sudo gem install packetgen
to install it on my Linux machine it raised an error:
ERROR: Error installing packetgen:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pcaprub-0.12.4/ext/pcaprub_c
/usr/bin/ruby2.3 -r ./siteconf20181009-29130-us1azm.rb extconf.rb
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/pcaprub-0.12.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0 /pcaprub-0.12.4/gem_make.out [here][1]
I ran the command as sudo, but got the same error. Does anyone know what I'm doing wrong here? The link to installation instructions is here.
Don't use sudo gem install but rather it is highly recommended that you use a ruby version manager, probably RVM, for more reasons why, see 'sudo gem install' or 'gem install' and gem locations
Based on your error it looks like you're trying to use your system ruby which will likely have permission and/or library dependency issues. These are easily solved by using a version manager which has many advantages including the ability to use different ruby versions on the same system and not having to use sudo or root level installs of gems.
You can install RVM from here
Instructions on gem link you posted do say gem depends on sudo apt install libpcap-dev which is a system lib your gem needs to build. I assume you did that step already right?
So I attempted to install Jekyll on Windows through Cygwin and I encountered an error when I tried to install Jekyll through Cygwin. Here is the output.
Michael#X556UAK: ~$ gem install jekyll
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /c/Users/Michael/.gem/ruby/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/usr/bin/ruby.exe -r ./siteconf20171011-7692-lgoixq.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /c/Users/Michael/.gem/ruby/2.3.0/gems/ffi- 1.9.18 for inspection.
Results logged to /c/Users/Michael/.gem/ruby/2.3.0/extensions/x86_64-cygwin/2.3.0/ffi-1.9.18/gem_make.out
I conducted some research online and I wasn't able to find a solution. I tried running Cygwin as an administrator and I still got that error message.
What can I do to fix this issue?
I had the same issue when installing Jekyll and Ruby in the Windows 10 Bash Linux Subsystem. It turned out, that the development package from Ruby was missing. I had to install it first:
sudo apt-get install ruby2.4-dev
In my case. Try to install the dev package in Cygwin package manager, in your case its version 2.3.
Andy
For the record, I encountered the same problem Michael did, and installing the ruby-devel package (using the Cygwin Setup installer) solved my problem. A missing *-devel Cygwin package is a common cause of errors about missing header files.