DEV Community

loading...

Fix for Erlang installation with asdf on macOS 11 Big Sur

Krzysztof Kempiński
・2 min read

Issue

There is an open issue with installing Erlang on macOS 11 Big Sur - https://github.com/erlang/otp/pull/2865

I use asdf (https://asdf-vm.com/#/) to manage versions of my local Elixir and Erlang applications. Recently I noticed that when I want to install (using asdf install ) Erlang version specified in .tool-versions file I see that error:

You are natively building Erlang/OTP for a later version of MacOSX
  than current version (11.1). You either need to
  cross-build Erlang/OTP, or set the environment variable
  MACOSX_DEPLOYMENT_TARGET to 11.1 (or a lower version).
Enter fullscreen mode Exit fullscreen mode

Solution

I manage to overcome this. My strategy was to install desired Erlang version with another tool to build and manage Erlang instances - kerl (https://github.com/kerl/kerl) - and inject that installation to asdf.

Steps to solve the issue:

  1. Install Kerl (I assume you use Homebrew).
    $ brew install kerl

  2. Set configuration options for Kerl.
    $ export KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac"

  3. Try to build your version of Erlang (it will fail!). In that example I'm installing version 21.3.8. If you want another version, just replace 21.3.8 to a version you want in all following commands.
    $ kerl build 21.3.8 21.3.8

  4. Open OTP configuration file (I assume you use VSCode - that's why you can see code. Replace with your editor.)
    $ code ~/.kerl/builds/21.3.8/otp_src_21.3.8/configure.in

  5. Find that line
    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > $int_macosx_version
    and replace it with that line:
    #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > $int_macosx_version && false

  6. Try to build it again. Now it should work. Will take some time so be patient!
    $ kerl build 21.3.8 21.3.8

  7. Make a directory for a new version of Erlang in your asdf directory.
    $ mkdir ~/.asdf/installs/erlang/21.3.8

  8. Install (copy) Erlang installed via kerl to asdf.
    $ kerl install 21.3.8 ~/.asdf/installs/erlang/21.3.8

  9. Close your console and open again (or open new window) and go to you project. Run asdf install to ensure you have your Elixir and Erlang versions installed.
    $ asdf install

  10. Compile your Elixir app.
    $ mix compile

And that's it!

If you have any comments or questions, find my on Twitter: https://twitter.com/k_kempinski

Discussion (0)