[openstreetmap/openstreetmap-website] Error in bundle exec db:create (Issue #5281)

Emin Kocan notifications at github.com
Thu Mar 27 07:26:10 UTC 2025


kcne left a comment (openstreetmap/openstreetmap-website#5281)

I encountered the same issue on my M4 Mac and found a solution. The problem is that the `gd2-ffij` gem can't find the GD2 library in the Homebrew installation path.

Looking at the `gd2-ffij` gem's source code, it searches for the library in these paths:
```ruby
paths = if ENV['GD2_LIBRARY_PATH']
  [ ENV['GD2_LIBRARY_PATH'] ]
else
  [ '/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu' ]
end
```

As you can see, it doesn't include Homebrew's library path (`/opt/homebrew/lib`), which is where the library is installed on M1 Macs.

Here's how to fix it:

1. First, make sure GD2 is installed via Homebrew:
```bash
brew install gd
```

2. Then, set the `GD2_LIBRARY_PATH` environment variable to point to the Homebrew GD2 library location:
```bash
export GD2_LIBRARY_PATH=/opt/homebrew/Cellar/gd/2.3.3_6/lib
```

3. After setting this environment variable, try running your Rails commands again:
```bash
bundle exec rails db:create
```

The issue occurs because the `gd2-ffij` gem doesn't include Homebrew's library path in its search locations. I will open a PR to the `gd2-ffij` gem repository to add support for Homebrew installations.

For now, setting the `GD2_LIBRARY_PATH` environment variable is a workaround that allows the gem to find the library in the Homebrew installation path.

You might want to add this environment variable to your shell configuration file (`.zshrc` or `.bashrc`) to make it permanent:
```bash
echo 'export GD2_LIBRARY_PATH=/opt/homebrew/Cellar/gd/2.3.3_6/lib' >> ~/.zshrc
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/5281#issuecomment-2756995012
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/issues/5281/2756995012 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250327/3198df79/attachment-0001.htm>


More information about the rails-dev mailing list