Missing libgd when building gem native extension - ruby-on-rails

In our Rails project we want to use the gem local-fastimage_resize which requires libgd. According to the doc (and the Internet) it should be possible to install it by means of homebrew but when we try to install the gem it can't find the library.
Here are some logs from my M1 mac:
$ brew info libgd
==> gd: stable 2.3.3 (bottled), HEAD
Graphics library to dynamically manipulate images
https://libgd.github.io/
/opt/homebrew/Cellar/gd/2.3.3_3 (33 files, 1.5MB) *
Poured from bottle on 2022-10-10 at 12:18:49
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gd.rb
License: Cannot Represent
==> Dependencies
Required: fontconfig ✔, freetype ✔, jpeg-turbo ✔, libavif ✔, libpng ✔, libtiff ✔, webp ✔
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 147,026 (30 days), 503,823 (90 days), 1,624,252 (365 days)
install-on-request: 17,867 (30 days), 55,417 (90 days), 144,616 (365 days)
build-error: 0 (30 days)
$ gem install local-fastimage_resize -- --with-gdlib=/opt/homebrew/Cellar/gd/2.3.3_3
Building native extensions with: '--with-gdlib=/opt/homebrew/Cellar/gd/2.3.3_3'
This could take a while...
ERROR: Error installing local-fastimage_resize:
ERROR: Failed to build gem native extension.
current directory: /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/local-fastimage_resize-3.4.0/ext/fastimage_native_resize
/Users/jgallaso/.asdf/installs/ruby/2.6.8/bin/ruby -I /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/2.6.0 -r ./siteconf20221010-18826-otaeca.rb extconf.rb --with-gdlib\=/opt/homebrew/Cellar/gd/2.3.3_3
checking for -l/opt/homebrew/Cellar/gd/2.3.3_3... no
missing libgd
*** 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
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/jgallaso/.asdf/installs/ruby/2.6.8/bin/$(RUBY_BASE_NAME)
--with-gdlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-21/2.6.0/local-fastimage_resize-3.4.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/local-fastimage_resize-3.4.0 for inspection.
Results logged to /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-21/2.6.0/local-fastimage_resize-3.4.0/gem_make.out
I've also tried installing libgd manually following instructions in INSTALL but no matter the path --with-gdlib it will return the same error.
Any ideas? 😖

Related

Can't install RMagick 4.2.3

I'm running Debian WSL 2 and I cannot install any version of RMagick.
I installed imagemagick#6 via homebrew and after installation I saw following:
imagemagick#6 is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew,
because this is an alternate version of another formula.
If you need to have imagemagick#6 first in your PATH, run:
echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick#6/bin:$PATH"' >> ~/.zshrc
For compilers to find imagemagick#6 you may need to set:
export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/imagemagick#6/lib"
export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/imagemagick#6/include"
For pkg-config to find imagemagick#6 you may need to set:
export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick#6/lib/pkgconfig"
I followed all the instructions above
then I tried to install RMagick via gem install rmagick -v '4.1.2' --source 'https://rubygems.org/'
and got output:
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rmagick-4.1.2/ext/RMagick
/home/ketch/.asdf/installs/ruby/2.7.1/bin/ruby -I /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0 -r ./siteconf20211106-21975-1odkmjc.rb extconf.rb
checking for brew... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
ERROR: Can't install RMagick 4.1.2. Can't find ImageMagick with pkg-config
*** 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
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/ketch/.asdf/installs/ruby/2.7.1/bin/$(RUBY_BASE_NAME)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-4.1.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rmagick-4.1.2 for inspection.
Results logged to /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-4.1.2/gem_make.out
I tried to install rmagick on my WSL debian, WSL ubuntu, and on Manjaro through virtual machine, everytime the same error

Cannot install uchardet gem on Mac OS catalina

Recently I got the following errors when I tried to install the uchardet GEM in MacOS catalina,Even I specific the ICU version and lib, it still doesn't work, anyone have ideas?
Installing uchardet 0.2.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/xxx/.rvm/gems/ruby-2.6.4/gems/uchardet-0.2.0/ext
/Users/xxx/.rvm/rubies/ruby-2.6.4/bin/ruby -I /Users/xxx/.rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200420-38494-q9y0cf.rb extconf.rb
Could not find ICU libraries and/or development tools. Try installing "icu-devtools" or "icu" package.
*** 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
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/xxx/.rvm/rubies/ruby-2.6.4/bin/$(RUBY_BASE_NAME)
extconf failed, exit code 1
Gem files will remain installed in /Users/xxx/.rvm/gems/ruby-2.6.4/gems/uchardet-0.2.0 for inspection.
Results logged to /Users/xxx/.rvm/gems/ruby-2.6.4/extensions/x86_64-darwin-19/2.6.0/uchardet-0.2.0/gem_make.out
I was able to reproduce this on my mac:
I fixed this error by re-installing and re-linking icu4c
brew install icu4c
brew link icu4c --force # if it shows you an error and tells you to add the path manually add them
restarted my terminal then re-installed the gem (i also tried this)
you will know it's working when you have which icu-config working https://github.com/dmgk/uchardet/blob/506105c5322fe3cde7ce3e2b2868f875b9b57230/ext/extconf.rb#L3-L6
however now i have another error uchardet.c:2:10: fatal error: 'unicode/ucsdet.h' file not found i do think the gems needs better configuration around this

Configuring Fog to install in Ruby on Rails project

I'm learning ruby on rails and have had my project hosted on c9.io. In the process of migrating over to Amazon AWS Cloud9 I'm having to reinstall my gems to my project. I am getting a config error while trying to build gem native extensions.
I'm not actually sure how to configure this gem before I enter 'gem install fog' into the command line. I've tried searching on the Fog website but I can't find the info on their page.
The error is:
Building native extensions. This could take a while...
ERROR: Error installing fog:
ERROR: Failed to build gem native extension.
current directory: /home/ubuntu/.rvm/gems/ruby-2.3.4/gems/ovirt-engine-sdk-4.3.0/ext/ovirtsdk4c
/home/ubuntu/.rvm/rubies/ruby-2.3.4/bin/ruby -r ./siteconf20190515-17400-2yzzer.rb extconf.rb
checking for xml2-config... no
*** 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
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/ubuntu/.rvm/rubies/ruby-2.3.4/bin/$(RUBY_BASE_NAME)
--with-libxml2-config
--without-libxml2-config
--with-pkg-config
--without-pkg-config
extconf.rb:29:in `<main>': The "libxml2" package isn't available. (RuntimeError)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/ubuntu/.rvm/gems/ruby-2.3.4/extensions/x86_64-linux/2.3.0/ovirt-engine-sdk-4.3.0/mkmf.log
extconf failed, exit code 1
The mkmf.log says:
find_executable: checking for xml2-config... -------------------- no
--------------------
"pkg-config --exists libxml2"
package configuration for libxml2 is not found
I just don't know how to translate this log message into my codebase so I can install fog and continue working on my app.
Instead of
gem 'fog'
Use
gem 'fog-aws'
In your gem file and it should work.
Try installing xml2 development package:
apt-get install libxml2-dev
This should work! (You might need to re-install Ruby after that.)

rmagick on OSX Mavericks - "Can't find Magick-config in ..."

When I try to install rmagick on OSX Mavericks, I get this error:
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/adam/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for /usr/bin/clang... yes
checking for Magick-config... no
Can't install RMagick 2.13.2. Can't find Magick-config in /opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/Users/adam/.rvm/gems/ruby-2.0.0-p353/bin:/Users/adam/.rvm/gems/ruby-2.0.0-p353#global/bin:/Users/adam/.rvm/rubies/ruby-2.0.0-p353/bin:/Users/adam/.rvm/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:#/usr/local/bin:/usr/local/mysql-5.6.13-osx10.7-x86_64/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/ImageMagick/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/mysql/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. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/adam/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
extconf failed, exit code 1
Gem files will remain installed in /Users/adam/.rvm/gems/ruby-2.0.0-p353/gems/rmagick-2.13.2 for inspection.
Results logged to /Users/adam/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-13/2.0.0/rmagick-2.13.2/gem_make.out
In ~/.bash_profile is following:
MYSQL=/usr/local/mysql/bin
export PATH=$PATH:$MYSQL
#export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
export PG_DUMP="/Applications/Postgres.app/Contents/MacOS/bin/"
#PATH=$PG_DUMP:$PATH
#export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH=/usr/local/bin:$PATH
There's no such a path as is in the error output, where does it comes from and how can I fix it?
Thank you.
Do you have ImageMagick installed? Install it via homebrew:
brew install imagemagick

Failed to build gem native extension while installing rmovie gem

I am trying to install rmovie gem on Ubuntu Desktop 12.04 LTS. ffmpeg is installed but I'm getting this error:
$ gem install rmovie
Building native extensions. This could take a while...
ERROR: Error installing rmovie:
ERROR: Failed to build gem native extension.
/home/ror_dev/.rvm/rubies/ruby-1.9.3-p362/bin/ruby extconf.rb
gcc -c -fpic -g qp_movie.c -o qp_movie.o
In file included from qp_movie.c:4:0:
qp_util.h:4:28: fatal error: ffmpeg/avcodec.h: No such file or directory
compilation terminated.
make: *** [qp_movie.o] Error 1
checking for avcodec_init() in -lavcodec... yes
checking for av_register_all() in -lavformat... yes
checking for quadrupel_init() in -lquadrupel... no
*** 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
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/ror_dev/.rvm/rubies/ruby-1.9.3-p362/bin/ruby
--with-ffmpeg-dir
--without-ffmpeg-dir
--with-ffmpeg-include
--without-ffmpeg-include=${ffmpeg-dir}/include
--with-ffmpeg-lib
--without-ffmpeg-lib=${ffmpeg-dir}/lib
--with-quadrupel-dir
--without-quadrupel-dir
--with-quadrupel-include
--without-quadrupel-include=${quadrupel-dir}/include
--with-quadrupel-lib
--without-quadrupel-lib=${quadrupel-dir}/lib
--with-avcodeclib
--without-avcodeclib
--with-avformatlib
--without-avformatlib
--with-quadrupellib
--without-quadrupellib
extconf failed: need quadrupel library
First attempt was to relocate avcodec to where installer is searching for it. No success. Next - correcting paths in quadrupel files to point it to where avcodec is located. No success.
What is this quadrupel thing and how to force it to work?
Or maybe there is some replacement for rmovie?
Use github.com/streamio/streamio-ffmpeg, it is more actively developed. rmovie was developed in 2006 and it may not be compatible with the current version of ffmpeg
Do like this -
1) Keep the gem in a gemfile -
gem "rmovie", "~> 0.5.1"
2) Run bundle install
If still get errors try:
sudo apt-get install ffmpeg libavcodec-extra-52
If package not found try:
sudo apt-get install ffmpeg libavcodec-extra-53
you can also try to install the libmp3lame0 package:
sudo apt-get install libmp3lame0

Resources