“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay who are based in Denmark...”

Rob Lacey
Senior Software Engineer, Copenhagen, Denmark

Getting ruby-libgd installed

As per usual native extensions don’t always install 1st time. Damn…

bundle add ruby-libgd
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching gem metadata from https://rubygems.org/.........
Fetching ruby-libgd 0.1.9
Installing ruby-libgd 0.1.9 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

The error is right there.

gem install ruby-libgd
Building native extensions. This could take a while...
ERROR:  Error installing ruby-libgd:
	ERROR: Failed to build gem native extension.

    current directory: /Users/rl/.asdf/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/gems/ruby-libgd-0.1.9/ext/gd
/Users/rl/.asdf/installs/ruby/3.4.6/bin/ruby extconf.rb
checking for -lgd... no
libgd not found

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/rl/.asdf/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/extensions/arm64-darwin-24/3.4.0/ruby-libgd-0.1.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/rl/.asdf/installs/ruby/3.4.6/lib/ruby/gems/3.4.0/gems/ruby-libgd-0.1.9 for inspection.

Looks like libgd is already installed.

brew install libgd
==> Auto-updating Homebrew...
Adjust how often this is run with `$HOMEBREW_AUTO_UPDATE_SECS` or disable with
`$HOMEBREW_NO_AUTO_UPDATE=1`. Hide these hints with `$HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).
==> Downloading https://ghcr.io/v2/homebrew/core/portable-ruby/blobs/sha256:1c98fa49eacc935640a6f8e10a2bf33f14cfc276804b71ddb658ea45ba99d167
##################################################################################################################################################################################### 100.0%
==> Pouring portable-ruby-3.4.8.arm64_big_sur.bottle.tar.gz
==> Auto-updated Homebrew!
Updated 4 taps (heroku/brew, mongodb/brew, homebrew/core and homebrew/cask).

---8<----

You have 125 outdated formulae and 2 outdated casks installed.

Warning: gd 2.3.3_6 is already installed and up-to-date.
To reinstall 2.3.3_6, run:
  brew reinstall gd

So I need to include the path the native libraries when installing.

gem install ruby-libgd -- --with-gd-include=/opt/homebrew/include --with-gd-lib=/opt/homebrew/lib
rl@loathsome fossa % bundle install
Bundle complete! 24 Gemfile dependencies, 125 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
1 installed gem you directly depend on is looking for funding.
  Run `bundle fund` for details