<span style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">
<p dir="auto">I encountered the same issue on my M4 Mac and found a solution. The problem is that the <code class="notranslate">gd2-ffij</code> gem can't find the GD2 library in the Homebrew installation path.</p>
<p dir="auto">Looking at the <code class="notranslate">gd2-ffij</code> gem's source code, it searches for the library in these paths:</p>
<div class="highlight highlight-source-ruby" dir="auto"><pre class="notranslate"><span class="pl-s1">paths</span> <span class="pl-c1">=</span> <span class="pl-k">if</span> <span class="pl-c1">ENV</span><span class="pl-kos">[</span><span class="pl-s">'GD2_LIBRARY_PATH'</span><span class="pl-kos">]</span>
<span class="pl-kos">[</span> <span class="pl-c1">ENV</span><span class="pl-kos">[</span><span class="pl-s">'GD2_LIBRARY_PATH'</span><span class="pl-kos">]</span> <span class="pl-kos">]</span>
<span class="pl-k">else</span>
<span class="pl-kos">[</span> <span class="pl-s">'/usr/local/{lib64,lib}'</span><span class="pl-kos">,</span> <span class="pl-s">'/opt/local/{lib64,lib}'</span><span class="pl-kos">,</span> <span class="pl-s">'/usr/{lib64,lib}'</span><span class="pl-kos">,</span> <span class="pl-s">'/usr/lib/{x86_64,i386}-linux-gnu'</span> <span class="pl-kos">]</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">As you can see, it doesn't include Homebrew's library path (<code class="notranslate">/opt/homebrew/lib</code>), which is where the library is installed on M1 Macs.</p>
<p dir="auto">Here's how to fix it:</p>
<ol dir="auto">
<li>First, make sure GD2 is installed via Homebrew:</li>
</ol>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate">brew install gd</pre></div>
<ol start="2" dir="auto">
<li>Then, set the <code class="notranslate">GD2_LIBRARY_PATH</code> environment variable to point to the Homebrew GD2 library location:</li>
</ol>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate"><span class="pl-k">export</span> GD2_LIBRARY_PATH=/opt/homebrew/Cellar/gd/2.3.3_6/lib</pre></div>
<ol start="3" dir="auto">
<li>After setting this environment variable, try running your Rails commands again:</li>
</ol>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate">bundle <span class="pl-c1">exec</span> rails db:create</pre></div>
<p dir="auto">The issue occurs because the <code class="notranslate">gd2-ffij</code> gem doesn't include Homebrew's library path in its search locations. I will open a PR to the <code class="notranslate">gd2-ffij</code> gem repository to add support for Homebrew installations.</p>
<p dir="auto">For now, setting the <code class="notranslate">GD2_LIBRARY_PATH</code> environment variable is a workaround that allows the gem to find the library in the Homebrew installation path.</p>
<p dir="auto">You might want to add this environment variable to your shell configuration file (<code class="notranslate">.zshrc</code> or <code class="notranslate">.bashrc</code>) to make it permanent:</p>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate"><span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">'</span>export GD2_LIBRARY_PATH=/opt/homebrew/Cellar/gd/2.3.3_6/lib<span class="pl-pds">'</span></span> <span class="pl-k">>></span> <span class="pl-k">~</span>/.zshrc</pre></div><p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/5281#issuecomment-2756995012">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLIWZLYT7KZ3DUR3AO32WOKYFAVCNFSM6AAAAABQOA3NISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONJWHE4TKMBRGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJEDGDXRK5T3GNNPR32WOKYFA5CNFSM6AAAAABQOA3NISWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTVEKRT4I.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/5281/2756995012</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
</span>
<div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img alt="kcne" height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/76796906?s=20&v=4" /><strong>kcne</strong> left a comment <a href="https://github.com/openstreetmap/openstreetmap-website/issues/5281#issuecomment-2756995012">(openstreetmap/openstreetmap-website#5281)</a></div>
<p dir="auto">I encountered the same issue on my M4 Mac and found a solution. The problem is that the <code class="notranslate">gd2-ffij</code> gem can't find the GD2 library in the Homebrew installation path.</p>
<p dir="auto">Looking at the <code class="notranslate">gd2-ffij</code> gem's source code, it searches for the library in these paths:</p>
<div class="highlight highlight-source-ruby" dir="auto"><pre class="notranslate"><span class="pl-s1">paths</span> <span class="pl-c1">=</span> <span class="pl-k">if</span> <span class="pl-c1">ENV</span><span class="pl-kos">[</span><span class="pl-s">'GD2_LIBRARY_PATH'</span><span class="pl-kos">]</span>
<span class="pl-kos">[</span> <span class="pl-c1">ENV</span><span class="pl-kos">[</span><span class="pl-s">'GD2_LIBRARY_PATH'</span><span class="pl-kos">]</span> <span class="pl-kos">]</span>
<span class="pl-k">else</span>
<span class="pl-kos">[</span> <span class="pl-s">'/usr/local/{lib64,lib}'</span><span class="pl-kos">,</span> <span class="pl-s">'/opt/local/{lib64,lib}'</span><span class="pl-kos">,</span> <span class="pl-s">'/usr/{lib64,lib}'</span><span class="pl-kos">,</span> <span class="pl-s">'/usr/lib/{x86_64,i386}-linux-gnu'</span> <span class="pl-kos">]</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">As you can see, it doesn't include Homebrew's library path (<code class="notranslate">/opt/homebrew/lib</code>), which is where the library is installed on M1 Macs.</p>
<p dir="auto">Here's how to fix it:</p>
<ol dir="auto">
<li>First, make sure GD2 is installed via Homebrew:</li>
</ol>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate">brew install gd</pre></div>
<ol start="2" dir="auto">
<li>Then, set the <code class="notranslate">GD2_LIBRARY_PATH</code> environment variable to point to the Homebrew GD2 library location:</li>
</ol>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate"><span class="pl-k">export</span> GD2_LIBRARY_PATH=/opt/homebrew/Cellar/gd/2.3.3_6/lib</pre></div>
<ol start="3" dir="auto">
<li>After setting this environment variable, try running your Rails commands again:</li>
</ol>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate">bundle <span class="pl-c1">exec</span> rails db:create</pre></div>
<p dir="auto">The issue occurs because the <code class="notranslate">gd2-ffij</code> gem doesn't include Homebrew's library path in its search locations. I will open a PR to the <code class="notranslate">gd2-ffij</code> gem repository to add support for Homebrew installations.</p>
<p dir="auto">For now, setting the <code class="notranslate">GD2_LIBRARY_PATH</code> environment variable is a workaround that allows the gem to find the library in the Homebrew installation path.</p>
<p dir="auto">You might want to add this environment variable to your shell configuration file (<code class="notranslate">.zshrc</code> or <code class="notranslate">.bashrc</code>) to make it permanent:</p>
<div class="highlight highlight-source-shell" dir="auto"><pre class="notranslate"><span class="pl-c1">echo</span> <span class="pl-s"><span class="pl-pds">'</span>export GD2_LIBRARY_PATH=/opt/homebrew/Cellar/gd/2.3.3_6/lib<span class="pl-pds">'</span></span> <span class="pl-k">>></span> <span class="pl-k">~</span>/.zshrc</pre></div>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/5281#issuecomment-2756995012">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLIWZLYT7KZ3DUR3AO32WOKYFAVCNFSM6AAAAABQOA3NISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONJWHE4TKMBRGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJEDGDXRK5T3GNNPR32WOKYFA5CNFSM6AAAAABQOA3NISWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTVEKRT4I.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/5281/2756995012</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/5281#issuecomment-2756995012",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/5281#issuecomment-2756995012",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>