All notes tagged with scheme.

Guile Hoot on the Mac

Recently, I was exploring the Spritely Institute’s blog and discovered their project, Guile Hoot. This Scheme to WebAssembly compiler enables running Scheme code directly in web browsers, opening up new possibilities of using Scheme.

While the project’s documentation is tailored for Guix users (a natural choice for Guile enthusiasts), I’m stuck on MacOS and needed to adapt the setup process using Homebrew. To save you time and frustration, this is how I got it running:

First, install the latest version of Guile using Homebrew:

# This may take some time
brew install guile --HEAD

Next, set up the necessary environment variables. For Fish shell users like myself:

set -x GUILE_LOAD_PATH $brew_prefix/share/guile/site/3.0
set -x GUILE_LOAD_COMPILED_PATH $brew_prefix/lib/guile/3.0/site-ccache
set -x GUILE_SYSTEM_EXTENSIONS_PATH $brew_prefix/lib/guile/3.0/extensions

For Bash or ZSH users, use the following (replace brew_prefix with the actual path or set it as a variable):

export GUILE_LOAD_PATH=$brew_prefix/share/guile/site/3.0
export GUILE_LOAD_COMPILED_PATH=$brew_prefix/lib/guile/3.0/site-ccache
export GUILE_SYSTEM_EXTENSIONS_PATH=$brew_prefix/lib/guile/3.0/extensions

Now, let’s clone the Guile Hoot repository, configure, and compile it. Ensure that the prefix directory matches your brew_prefix:

git clone https://gitlab.com/spritely/guile-hoot.git
cd guile-hoot
./bootstrap.sh
./configure --prefix=/opt/homebrew
make
# No sudo needed when using Homebrew
make install

To verify your installation, launch the Guile REPL and test if the following command loads without errors:

scheme@(guile-user)> ,use (hoot compile)

If you don’t encounter any errors, congratulations! You’ve successfully set up Guile Hoot on your Mac. Now, let’s see if I can create a game in the browser with Scheme and WASM!