1

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

James
  • 387
  • 1
  • 11

1 Answers1

0

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.

james00794
  • 1,137
  • 7
  • 14