ERROR: Error installing psych: ERROR: Failed to build gem native extension - windows

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

Related

Gem will not install sqlite3 despite sqlite3 being installed (Mac)

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

Rubocop installing error: Failed to build gems

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.

Failed to install gem mysql2 on Ubuntu 16.04.3 LTS

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

What does XCode installing do when solving 'gem install sqilte3' error(Failed to build gem native extension.)?

I was trying to install gem sqlite3 but failed with error below.
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
/usr/local/opt/ruby/bin/ruby -r ./siteconf20151016-8328-1i1buur.rb extconf.rb --with-sqlite3-dir /usr/bin
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.
.....
I just searched through and solved it via installing XCode before installing sqlite3, can anyone tell me the reason? What does XCode actually do?
I am a newbie on those gem of Ruby.
Installing XCode (or more precisely the XCode command line tools) will also install the toolchain needed to compile the native extensions (written in C) needed by the sqlite3 gem.

Error Installing github-pages gem in command line on Windows

I've managed to setup Ruby 1.9.3 and devkit as well as jekyll and a bunch of other gems. However, now when I try installing github-pages gem (gem install github-pages) I get the following error:
Note: I've tried running command line as an admin with no more success
Here's the output from my command line:
Temporarily enhancing PATH to include DevKit... Building native
extensions. This could take a while... ERROR: Error installing
github-pages:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20141208-60036-a7hzln.rb extconf.rb creating Makefile
make clean Makefile:165: *** target pattern contains no `%'. Stop.
make Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/redcarpet
-3.1.2 for inspection. Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/re
dcarpet-3.1.2/gem_make.out
Well I couldn't find the answer on SO so I looked around elsewhere and was able to find the answer on GitHub. Please see here:
https://github.com/rubygems/rubygems/issues/977
Basically, if you're getting this error on Windows using RubyGems 1.9.3 (which I was) you need to downgrade to 1.8.29 until this is fixed. Glad to know it's not just me making this error!
How to downgrade, you may be asking? On Windows:
gem update --system 1.8.29
I downgraded and had no trouble installing the other gem files I needed.

Resources