Windows gem install error: extconf.rb:301:in `assert_has_dev_libs!': invalid byte sequence in UTF-8 (ArgumentError) - ruby

I am new to ruby and wanted to add responsive images to my site. I decided to use jekyll-responsive-image. When the install gave me issues, I installed ImageMagick, thinking it was a dependency, following this. Then tried to install rmagick (assuming it is also a dependency) using both
gem install rmagick -v '4.1.2' --source 'https://rubygems.org/'
and
gem install rmagick --platform=ruby -- --with-opt-lib='C:/ImageMagick-7.0.10-Q16-HDRI/lib' --with-opt-include='C:/ImageMagick-7.0.10-Q16-HDRI/include'
The output of these are
checking for Ruby version >= 2.3.0... yes
checking for magick... yes
*** 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=${opt-dir}/include
--with-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=C:/Ruby27-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:301:in `assert_has_dev_libs!': invalid byte sequence in UTF-8 (ArgumentError)
from extconf.rb:267:in `assert_can_compile!'
from extconf.rb:18:in `initialize'
from extconf.rb:395:in `new'
from extconf.rb:395:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/rmagick-4.1.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rmagick-4.1.2 for inspection.
The log does not look helpful
assert_minimum_ruby_version!: checking for Ruby version >= 2.3.0... -------------------- yes
--------------------
find_executable: checking for magick... -------------------- yes
--------------------
It looks like the invalid byte sequence error is stopping me from installing any new gems. Based on other questions on stack overflow, I've tried to check that my path does not contain any specially characters. From this post, I set the user environment variables of LANG, LANGUAGE, and LC_ALL to en_US.UTF-8, and LC_CTYPE to C.BINARY. RUBYOPT is set to -Eutf-8.
How can I solve this error? Keep in mind I'm on Windows 10. Thank you

I just ran into this.
When installing rmagick, the extconf.rb file is running the magick command at the command prompt and running a regex on the output to check the version number. You can reproduce this issue easily by making a simple ruby file with the following content (copied from extconf.rb):
`magick --version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
Run this file, and you'll see the same invalid byte sequence exception. We can verify this like so:
str = `magick --version`
str.valid_encoding? # false
From inspecting the output of that magick command on the command prompt, it looks like the version output uses the © symbol (\xA9), which appears to be throwing the exception.
I had an old imagemagick installer lying around (~2 months old) which used a simple C instead of © in the copyright output, and that version of imagemagick seems to allow rmagick to install properly. You may want to dig around for an older installer and see if this resolves your issue.

Related

Homebrew: Error running 'requirements_osx_brew_libs_install gcc#6' on Mac10.13.6

I can't install ruby 3.0.0 through my powershell, when I try rvm install 3.0.0 I receive a beautiful error:
Error running 'requirements_osx_brew_libs_install gcc#6',
please read /Users/ben/.rvm/log/1673079096_ruby-3.0.0/package_install_gcc#6.log
Requirements installation failed with status: 1.
I feel like I've tried everything to resolve this problem but without success.
-This is my gcc version:
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 10.0.0 (clang-1000.10.44.4) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
-homebrew version:
Homebrew 3.6.17-66-g974984d Homebrew/homebrew-core (git revision 0149ce7e63e; last commit 2023-01-07)
-rvm version:
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
-ruby version:
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
-which ruby:
/usr/bin/ruby
And when I run rvm install 3.0.0 this is what I receive:
Error: Invalid usage: This command requires at least 1 text or regex argument.
Usage: brew search, -S [options] text|/regex/ [...]
Perform a substring search of cask tokens and formula names for text. If
text is flanked by slashes, it is interpreted as a regular expression. The
search for text is extended online to homebrew/core and homebrew/cask.
--formula, --formulae Search online and locally for formulae.
--cask, --casks Search online and locally for casks.
--desc Search for formulae with a description
matching text and casks with a name or
description matching text.
--eval-all Evaluate all available formulae and casks,
whether installed or not, to search their
descriptions. Implied if HOMEBREW_EVAL_ALL is
set.
--pull-request Search for GitHub pull requests containing
text.
--open Search for only open GitHub pull requests.
--closed Search for only closed GitHub pull requests.
--repology Search for text in the given database.
--macports Search for text in the given database.
--fink Search for text in the given database.
--opensuse Search for text in the given database.
--fedora Search for text in the given database.
--archlinux Search for text in the given database.
--debian Search for text in the given database.
--ubuntu Search for text in the given database.
-d, --debug Display any debugging information.
-q, --quiet Make some output more quiet.
-v, --verbose Make some output more verbose.
-h, --help Show this message.
Error: Invalid usage: This command requires at least 1 text or regex argument.
Installing requirements for osx_brew.
Updating system..........
Installing required packages: gcc#6........There were package installation errors, make sure to read the log.
Try `brew tap --repair` and make sure `brew doctor` looks reasonable.
Check Homebrew requirements https://docs.brew.sh/Installation
.
Error running 'requirements_osx_brew_libs_install gcc#6',
please read /Users/benoitlardinois/.rvm/log/1673081014_ruby-3.0.0/package_install_gcc#6.log
Requirements installation failed with status: 1.
So, if I run brew install gcc#6, I receive:
Warning: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from MacHomebrew on Twitter.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.
Warning: gcc#6 has been deprecated because it is deprecated upstream!
==> Fetching dependencies for gcc#6: isl, mpfr and libmpc
==> Fetching isl
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed
Already downloaded: /Users/benoitlardinois/Library/Caches/Homebrew/downloads/195208ba31cadc265ea97bb8aad4e78caab1200daf4d855e6c839b5f987f92db--configure-big_sur.diff
==> Downloading https://libisl.sourceforge.io/isl-0.25.tar.xz
Already downloaded: /Users/benoitlardinois/Library/Caches/Homebrew/downloads/dce6d1ed4d25c923a4ad350c4b9cdf03406f649cd55be8c385814703502b5c81--isl-0.25.tar.xz
==> Fetching mpfr
==> Downloading https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.0.tar.xz
Already downloaded: /Users/benoitlardinois/Library/Caches/Homebrew/downloads/2b7a1efec00f58b200d550146d18563516f005674020aa39ca2cd6666cb1d215--mpfr-4.2.0.tar.xz
==> Fetching libmpc
==> Downloading https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz
Already downloaded: /Users/benoitlardinois/Library/Caches/Homebrew/downloads/22a255b07a458ea7bd9717c0d1509282a69135dd842aa6b64144820c50bfd208--mpc-1.3.1.tar.gz
==> Fetching gcc#6
==> Downloading https://ftp.gnu.org/gnu/gcc/gcc-6.5.0/gcc-6.5.0.tar.xz
Already downloaded: /Users/benoitlardinois/Library/Caches/Homebrew/downloads/0a7c1b4768113746153c6e06f4ea6b2abf2d8ba48a68bf28f7c686b70117540e--gcc-6.5.0.tar.xz
==> Installing dependencies for gcc#6: isl, mpfr and libmpc
==> Installing gcc#6 dependency: isl
==> Patching
==> Applying configure-big_sur.diff
patching file configure
Hunk #1 succeeded at 13866 (offset 5133 lines).
==> ./configure --prefix=/usr/local/Cellar/isl/0.25 --with-gmp=system --with-gmp-prefix=/usr/local/op
==> make
Last 15 lines from /Users/benoitlardinois/Library/Logs/Homebrew/isl/02.make:
constexpr value_type& value() &
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:933:33: note: candidate function has been explicitly made unavailable
constexpr value_type const& value() const&
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:951:28: note: candidate function not viable: no known conversion from 'optional<...>' to 'optional<...>' for object argument
constexpr value_type&& value() &&
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/optional:960:34: note: candidate function not viable: no known conversion from 'optional<...>' to 'const optional<...>' for object argument
constexpr value_type const&& value() const&&
^
2 errors generated.
make[2]: *** [isl_test_cpp17.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Do not report this issue to Homebrew/brew or Homebrew/core!
Error: You are using macOS 10.13.
We (and Apple) do not provide support for this old version.
It is expected behaviour that some formulae will fail to build in this old version.
It is expected behaviour that Homebrew will be buggy and slow.
Do not create any issues about this on Homebrew's GitHub repositories.
Do not create any issues even if you think this message is unrelated.
Any opened issues will be immediately closed without response.
Do not ask for help from MacHomebrew on Twitter.
You may ask for help in Homebrew's discussions but are unlikely to receive a response.
Try to figure out the problem yourself and submit a fix as a pull request.
We will review it but may or may not accept it.
I'm in despair, I don't know what I'm supposed to do.
The warning is clearly stating that macOS 10.13 is too old, so the best thing is to upgrade the OS - there were several failed attempts to build Ruby 3.0 - see https://github.com/rvm/rvm/issues/5055
Also, GCC below version 10 are deprecated - see homebrew issue https://github.com/Homebrew/homebrew-core/pull/110163
Though, you can first try switching from rvm to rbenv - seems like someone get it done with rbenv on High Sierra - https://github.com/rvm/rvm/issues/5012#issuecomment-811858777

Perl can't install Glib on Mac Big Sur

I'm trying to install Gtk2 from CPAN on my Mac (Big Sur), but it requires Glib, and Glib install is failing. The tail of the installer output is here:
echo Generating POD...
Generating POD...
"/usr/bin/perl" -I blib/lib -I blib/arch -MGlib::GenPod -MGlib \
-e "add_types (qq(doctypes)); Glib::GenPod::set_copyright(qq/Copyright (C) 2003-2011 by the gtk2-perl team.\n\nThis software is licensed under the LGPL. See L<Glib> for a full notice.\n/); Glib::GenPod::set_main_mod(qq(Glib)); xsdoc2pod(q(build/doc.pl), q(blib/lib), q(build/podindex));"
Can't load 'blib/arch/auto/Glib/Glib.bundle' for module Glib: dlopen(blib/arch/auto/Glib/Glib.bundle, 0x0001): open("", O_RDONLY) failed with errno=2 at /System/Library/Perl/5.30/darwin-thread-multi-2level/DynaLoader.pm line 197.
at blib/lib/Glib/GenPod.pm line 21.
Compilation failed in require at blib/lib/Glib/GenPod.pm line 21.
BEGIN failed--compilation aborted at blib/lib/Glib/GenPod.pm line 21.
Compilation failed in require.
BEGIN failed--compilation aborted.
make: *** [build/podindex] Error 2
FAIL
! Installing Glib failed. See /Users/principal/.cpanm/work/1626461722.68580/build.log for details. Retry with --force to force install it.
Retry with --force gives the same results. The specified build.log file gives less detail than the console output above.
If I understand what it's telling me, it is that the GenPod.m module fails at the point where it is trying to "use Glib;". But when I look at the specified search point (blib/arch/auto/Glib/Glib.bundle) there is such a file there.
I'm using the Mac-installed Perl (5.30) and have had no other issues installing via CPAN. Any help would be appreciated. I would even welcome knowing how to bypass the "GenPod" step, as having working code is better than having documentation. The latest post I could find on the topic of Glib failing to install on Mac was four years ago in the El Capitan days, and the OP there was having an entirely different problem.

Issues installing libxml gem for ruby on windows

There are a few threads on questions similar to this, but none have proven effective. I attempted asking on the github page with no luck either.
When I attempt the standard command:
gem install libxml-ruby
I receive an error where the installer cannot find libxml2.dll. I found a stackoverflow thread with a similar issue and followed a user's guidelines here on where to grab the missing libraries and where to include them.
If I add arguments to the install command to point at the directories with the missing libraries using the following:
gem install libxml-ruby -- with-xml2-include=C:\Ruby200\include\libxml2 --with-iconv-include=C:\Ruby200\include
I now get an error where the installer can’t find a “iconv.h” header which is in my C:\Ruby200\include directory.
C:\Users\gonz102>gem install libxml-ruby -- with-xml2-include=C:/Ruby200/include
/libxml2 --with-iconv-include=C:/Ruby200/include
Temporarily enhancing PATH to include DevKit...
Building native extensions with: 'with-xml2-include=C:/Ruby200/include/libxml2 -
-with-iconv-include=C:/Ruby200/include'
This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb with-xml2-include=C:/Ruby200/include/libx
ml2 --with-iconv-include=C:/Ruby200/include
checking for libxml/xmlversion.h in /opt/include/libxml2,/opt/local/include/libx
ml2,/usr/local/include/libxml2,/usr/include/libxml2... yes
checking for xmlParseDoc() in -lxml2... yes
checking for rb_io_bufwrite() in ruby/io.h... yes
creating extconf.h
creating Makefile
make "DESTDIR="
compiling libxml.c
In file included from C:/Ruby200/include/libxml2/libxml/parser.h:810:0,
from ruby_libxml.h:7,
from libxml.c:1:
C:/Ruby200/include/libxml2/libxml/encoding.h:28:19: fatal error: iconv.h: No suc
h file or directory
compilation terminated.
make: *** [libxml.o] Error 1
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/libxml-ru
by-2.9.0 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/libxml-ruby-2.9.0/ext/libx
ml/gem_make.out
If anyone has any suggestions on what to investigate next or possible solutions I'd greatly appreciate it. I've been stumped on this for over a long while, coming back to it whenever I run into a project with libxml and would gladly take any advice.
Many thanks.
I was unsuccessful with installing libxml version 2.9.0 but 2.7.0 worked just fine. I should specify I'm running windows 7 and Ruby 2.0 32 bit. Here is what I had to do:
-I followed Wik's response here, grabbing all the missing libraries from them mingw64. Admittedly, I'm not sure if I needed all of them, but I sort of took a shotgun approach here.
Added the following to my system path:
Ruby200\lib\ruby\gems\2.0.0\gems\libxml-ruby-2.7.0-x86-mingw32\lib\libs
Executed the following in command line:
gem install libxml-ruby -v2.7.0 -- with-xml2-include:=C/Ruby200/include/libxml2 --with-iconv-include:=C:/Ruby200/include
After that, I the gem, at long last, installed and was actually usable.

FreeBSD make error File 5.19 supports only version 12 magic files. /usr/share/misc/magic.mgc is version 8

I'm having trouble reinstalling ProFTPD on a FreeBSD 10.1 setup. The server is newly upgraded from 10.0 to 10.1. When I start the make install clean process, these warnings first shows on screen.
===> proftpd-1.3.5_4 depends on shared library: libpcre.so
/usr/share/misc/magic, 93: Warning: Printf format `l' is not valid for type `lelong' in description `, %ld pages'
...
/usr/share/misc/magic, 15118: Warning: Printf format `l' is not valid for type `belong' in description `Volume %ld,'
/usr/share/misc/magic, 15609: Warning: Current entry does not yet have a description for adding a MIME type
file: File 5.19 supports only version 12 magic files. `/usr/share/misc/magic.mgc' is version 8
[: =: unexpected operator
- not found
And after i while, the make process stops with this error:
/bin/ln -s libpcre.so.1 /usr/ports/devel/pcre/work/stage/usr/local/lib/libpcre.so.3
====> Compressing man pages (compress-man)
===> Installing for pcre-8.35_2
===> Checking if pcre already installed
===> pcre-8.35_2 is already installed
You may wish to ``make deinstall'' and install this port again
by ``make reinstall'' to upgrade it properly.
If you really wish to overwrite the old port of pcre
without deleting it first, set the variable "FORCE_PKG_REGISTER"
in your environment or the "make install" command line.
*** Error code 1
Stop.
make[3]: stopped in /usr/ports/devel/pcre
*** Error code 1
Stop.
make[2]: stopped in /usr/ports/devel/pcre
*** Error code 1
Stop.
make[1]: stopped in /usr/ports/ftp/proftpd
*** Error code 1
Stop.
make: stopped in /usr/ports/ftp/proftpd
Seems that the file /usr/share/misc/magic.mgc is of a wrong version?
This might happens when I was upgrading from 10.0-RELEASE-p12 to 10.1-RELESE-p1?
If i run make install clean of the ProFTP port, and disable support for pcre, the process and install is successful.
But I believe that something is still broken?
My programming skills are limited, and also this level of error.
Please let me know if you have any ideas,
Thanks,
First of all, proftpd 1.3.5 is available as a binary package, it's much simpler to install it that way (pkg install proftpd).
Second - at first it looked like a port bug; as Etan said, there is a shell syntax error (something like '[ x == y ]' instead of '[ x = y ]'); those are common, and ports contain patches to fix those. However, there is a binary package, and packages are built from ports ("make package"), so port obviously does work on package build machines. So it's probably something specific to your environment.
If you really want to build from ports, try this: first, reinstall pcre. For some reason it had to be rebuilt, but failed to install, because it's already installed. So, "cd /usr/ports/*/pcre && make clean all deinstall reinstall". That should get rid of the second error. Then go back to "../*/proftpd" and see how far it goes.
But really, I'd try packages first. They have nothing in common with old pkg_add system, and are really nice.
freebsd-update diff for FreeBSD-SA-14:28.file seems wrong, and it breaks file(1).
Therefore simply pkg install file will be a workaround.

Errno::EEXIST File Exists error when installing 'ferret' gem from local .gem file

I am trying to install the ferret ruby gem on a RHEL zlinux (s390x architecture) machine, and am trying to install a .gem file after patching it so that it will compile.
But even trying to install the pristine fetched gem, it fails as follows:
[ me#s390x ]$ sudo gem fetch ferret
Downloaded ferret-0.11.6
[ me#s390x ]$ sudo gem install -lV ferret-0.11.6.gem
Installing gem ferret-0.11.6
Using local gem /home/rubyusr/rubygems/gems/cache/ferret-0.11.6.gem
/home/rubyusr/rubygems/gems/gems/ferret-0.11.6/bin
ERROR: While executing gem ... (Errno::EEXIST)
File exists - /home/rubyusr/rubygems/gems/gems/ferret-0.11.6/bin
None of the above-mentioned directories or files related to "ferret" existed before running this command.
Also strange is that /home/rubyusr/rubygems/gems/gems/ferret-0.11.6/bin is a directory, although maybe that is a normal complaint.
A final complicating factor is when I run the gem command I am actually running a shell script that sets the environment variables for my unusual rubygems directory (I haven't had any problems so far with this set up). Here is my gem shell script:
#!/bin/bash
export GEM_HOME=/home/rubyusr/rubygems/gems
export GEM_PREFIX=/home/rubyusr/rubygems
export RUBYLIB=$GEM_PREFIX/lib:/usr/lib/ruby:/usr/lib/ruby/site_ruby:/usr/lib/site_ruby
export GEM_PATH=$GEM_HOME
OUR_GEM_COMMAND=$GEM_PREFIX/bin/gem
$OUR_GEM_COMMAND $#
EDIT:
I forgot to add that running the gem install command normally does not seem to result in this error (but ferret fails to compile), with the error:
posh.h:515:4: error: #error POSH cannot determine target CPU
There is a bug in Debian asking for adding support for arm64:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770922
It needs adding a few lines in the file ext/posh.h to add support for that CPU:
--- a/ext/posh.h
+++ b/ext/posh.h
## -512,6 +512,11 ##
# define POSH_CPU_STRING "PA-RISC"
#endif
+#if defined __aarch64__
+# define POSH_CPU_AARCH64 1
+# define POSH_CPU_STRING "AArch64"
+#endif
+
#if !defined POSH_CPU_STRING
# error POSH cannot determine target CPU
# define POSH_CPU_STRING "Unknown" /* this is here for Doxygen's benefit */
Adding support for s390 was about adding these lines:
#if defined __s390__
# define POSH_CPU_S390 1
# define POSH_CPU_STRING "S/390"
#endif
if you know the corresponding values for S390/X, you can add them in there.

Resources