Header logo.
small hallucinations
homeyearstagsaboutrss

Using Elixir Observer on a Mac

tl;dr

On a Mac, if you want to use the Observer GUI for Elixir/Erlang, just use the Homebrew distribution of Erlang. It comes with wxWidgets correctly pre-configured.

Erlang distributions installed via asdf do not support Observer out of the box. When you install wxWidgets via homebrew separately, Erlang will complain that it was not compiled with the --enable-compat30 flag, making it incompatible. (Do not even think about compiling from the source code on your own.)

context

Elixir/Erlang ships with a GUI observer that shows how processes interact. This seems very helpful when you have a complex mix of Supervisors, GenServers, and processes.

For some reason, I couldn't use it on my Mac. The error message mentioned something about wx. I decided to look into it and came across this blog post. Following the instructions, I tried installing wxwidgets using Homebrew. The installation failed because a few dependencies were the x86_64 version, but they should have been arm64.

It took me some time to realize my Homebrew was, for some reason, for x86_64. I don't recall how that happened, but that explained why I remember occasionally seeing architecture mismatches when adding dependencies. I also had a version of Elixir installed from MacPorts. I removed MacPorts, removed Homebrew. Reinstalled Homebrew for the correct architecture.

Now with the right version of Homebrew in place, I installed wxWidgets from Homebrew again, carefully set environment variables including KERL_CONFIGURE_OPTIONS="--with-wx", and tried installing Erlang and Elixir using the ASDF version manager. Erlang failed to install with an error message that said something like: “wxWidgets was not compiled with --enable-compat30, wx will NOT be useable”.

So, I tried building wxWdigets from source code. It was ChatGPT who suggested all the steps: clone the repo and configure it with a few flags, notably --enable-compat30, which is exactly what the last error message indicated.

The configuration script then noticed missing submodules, which I downloaded following the instructions given by the script. I repeated this step a few times for a handful of missing submodules.

When I finally got the compilation working, I was quickly faced with an error message: fp.h was missing, which was required by the built-in libpng. ChatGPT told me to install libpng via Homebrew and pass a parameter to the configuration script. I did so and reran the configuration script. This then happened again with libtiff.

I said, “Argh. I just wanted to use :observe,” as I was about to give up.

At that very moment, ChatGPT finally brought this up, as if it were an afterthought.

Yeah, this rabbit hole is brutal. If your real goal is just :observer, you don’t actually need to hand-build wxWidgets at all. ... Use Homebrew’s Erlang (it comes with the GUI bits working on macOS).

Bruh...

Why didn't you tell me this before I attempted to compile C++ on my own?