Aspell for Ruby with MacPorts-Installed Aspell

April 03, 2009 · 1 min read

If you want to use Aspell from Ruby and you use MacPorts to manage software on your Mac, you'll likely hit a wall compiling the native extensions for RAspell. The error log is lengthy, but the important line is this:

raspell.h:6:20: error: aspell.h: No such file or directory

It can't find the Aspell headers, even though Aspell is installed via MacPorts. The fix is simple: tell RubyGems where MacPorts put everything.

# Install the Aspell port
sudo port install aspell
# Install the Ruby bindings, pointing at MacPorts' install location
sudo gem install raspell -- --with-opt-dir=/opt/local

That's it. The --with-opt-dir=/opt/local flag tells the native extension builder to look in MacPorts' prefix for headers and libraries, and everything compiles cleanly.

These posts are LLM-aided. Backbone, research, original writing, and structure by Craig. Editing by Craig + LLM. Proof-reading by Craig.