How do I install erlang using asdf

I’m trying to install erlang otp 22.x. I have installed elixir and erlang using asdf and I have set the global version as otp 23 and elixir latest. But one for one of my projects I need to install otp 22 but It somehow not able to install and I’m getting this error.

`asdf_22.1.7 is not a kerl-managed Erlang/OTP installation
The asdf_22.1.7 build has been deleted
Extracting source code
Building Erlang/OTP 22.1.7 (asdf_22.1.7), please wait...
Build failed.
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/netinet6/in6.h:212:30: note: previous declaration is here
extern const struct in6_addr in6addr_loopback;
^
2 errors generated.
make[4]: *** [obj/x86_64-apple-darwin19.6.0/opt/smp/socket_nif.o] Error 1
make[3]: *** [opt] Error 2
make[2]: *** [opt] Error 2
make[1]: *** [smp] Error 2
make: *** [emulator] Error 2

Please see /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7/otp_build_22.1.7.log for full details.`

I don’t know what is causing this. Do I have to uninstall the erlang version which I have installed?

I’m using macOS Catalina 10.15.6.

I followed these steps

  1. installed asdf using brew install asdf
  2. asdf plugin-add erlang
  3. asdf install erlang 22.1.8
`▶ brew install asdf
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
command-tab-plus virtualhostx

==> Downloading https://github.com/asdf-vm/asdf/archive/v0.7.8.tar.gz
Already downloaded: /Users/siddhant/Library/Caches/Homebrew/downloads/34d73b51ece171e6c4ffe51147d4599c5b7f78749b379dec98ab7dd9174bd595--asdf-0.7.8.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d

zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Summary
🍺 /usr/local/Cellar/asdf/0.7.8: 104 files, 219.6KB, built in 2 seconds

~
▶ asdf plugin-add erlang
initializing plugin repository...
Cloning into '/Users/siddhant/.asdf/repository'...
remote: Enumerating objects: 2224, done.
remote: Total 2224 (delta 0), reused 0 (delta 0), pack-reused 2224
Receiving objects: 100% (2224/2224), 502.74 KiB | 624.00 KiB/s, done.
Resolving deltas: 100% (1000/1000), done.

~
▶ asdf install erlang 22.1.7
Downloading kerl...
asdf_22.1.7 is not a kerl-managed Erlang/OTP installation
No build named asdf_22.1.7
Downloading OTP-22.1.7.tar.gz to /Users/siddhant/.asdf/plugins/erlang/kerl-home/archives
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 122 100 122 0 0 261 0 --:--:-- --:--:-- --:--:-- 261
100 52.4M 0 52.4M 0 0 7499k 0 --:--:-- 0:00:07 --:--:-- 8890k
Extracting source code
Building Erlang/OTP 22.1.7 (asdf_22.1.7), please wait...
Build failed.
^
CC obj/x86_64-apple-darwin19.6.0/opt/smp/prim_file_nif.o
CC obj/x86_64-apple-darwin19.6.0/opt/smp/zlib_nif.o
2 errors generated.
make[4]: *** [obj/x86_64-apple-darwin19.6.0/opt/smp/inet_drv.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [opt] Error 2
make[2]: *** [opt] Error 2
make[1]: *** [smp] Error 2
make: *** [emulator] Error 2

Please see /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7/otp_build_22.1.7.log for full details.

~ ⍉
▶ /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7/otp_build_22.1.7.log for full details.
zsh: permission denied: /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7/otp_build_22.1.7.log

~ ⍉
▶ /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7/otp_build_22.1.7.log
zsh: permission denied: /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7/otp_build_22.1.7.log

~ ⍉
▶ /Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.7

kerl-home/builds/asdf_22.1.7 master ✔ 63d4h
▶ ls
otp_build_22.1.7.log otp_src_22.1.7`

Above is the list of things I did and in the last, I get the same error every time. If you see if I go to this

this is the gist for this file when I go into this

/Users/siddhant/.asdf/plugins/erlang/kerl-home/builds/asdf_22.1.8/otp_build_22.1.8.log for full details.

1 Like

Have you tried this?

brew install autoconf
brew install wxmac
export KERL_CONFIGURE_OPTIONS="--without-javac"
asdf install erlang 22.1.7
1 Like

Can you explain? Why do we need this?

I tried all of the mention steps there but still it didn’t work

The MacOS installer from Erlang Solutions will give you an Erlang build that supports the GUI debugging tools. I’ve never been able to get those to work from asdf, brew, or Macports

https://packages.erlang-solutions.com/os-x-installer/ErlangInstaller1.0.2.dmg

Never used this. not sure about this. Can you tell me how it will help me?

I’ve never been able to get those to work from asdf, brew, or Macports

The key is to install wx before asking whichever tool (e.g. asdf) to compile Erlang. Erlang’s compile process skips compiling in bits where dependencies are missing (e.g. wx, unixodbc, java).

So…

brew install wxmac
and then
asdf install erlang 22.3.4

You can test that it worked with
iex> :observer.start()

Similarly, if you need odbc support you would need to brew install unixodbc before compiling Erlang.

Yeah but I installed wx before installing erlang. But it did not work.

I’ve found this https://stackoverflow.com/questions/61228561/unable-to-install-erlang-using-asdf-on-osx-10-15-4 and it seems building Erlang 21.x is impossible on Catalina

Edit: Yea, my bad

Yeah but I’m trying to install 22.x here.

Can someone tell me how to delete everything what asdf has installed and brew has installed. If I do from the start maybe it can work. But right now I don’t understand the problem here

Same problem here. If you’re on Catalina the issue is worse because IIRC wx 2.8 only supports 32bit and getting OTP to link against wx 3.x is a nightmare.

So is there any other way around? You’ve mentioned erlang installer but I don’t know the follow up steps and I want to install elixir later. But the main thing here I have to switch between older and newer otp version. That’s why I thought asdf will be good here in that case. Can you suggest if that I can do the same thing here?

Yes, the Erlang Solutions installer handles this nicely. You get a GUI to choose your releases:

The OTP versions are installed in your home: ~/.erlangInstaller/

find ~/.erlangInstaller -maxdepth 1
/Users/feld/.erlangInstaller
/Users/feld/.erlangInstaller/available-releases.json
/Users/feld/.erlangInstaller/default
/Users/feld/.erlangInstaller/22.3.4.1

the default is a symlink to the current version you want to be your default OTP version. Then you just update your $PATH to include ~/.erlangInstaller/default/bin and it’s ready to go.

On a Mac you can’t just update your PATH in your shell anymore, so make sure you add it to /etc/paths.d/$username file or some programs/utilities will not inherit the PATH.

edit: here’s the contents of my /etc/paths.d/feld file:

/Users/feld/bin
/Users/feld/.erlangInstaller/default/bin
/Users/feld/elixir-1.10.2/bin
/opt/local/bin/
/Users/feld/node_modules/.bin

So I use zshrc can I add the path there?

You can, but it won’t be picked up globally in MacOS. It might be fine for you, but if you run into problems you need to edit /etc/paths.d/$username and add it there too.

MacOS does not behave like a typical Linux/Unix anymore when it comes to environment variables.

Usually if I’m launching iterm2 for erlang so technially I should update the path there right? I didn’t understand properly where I can add this

~/.erlangInstaller
▶ ls
22.3.4.1                available-releases.json default

~/.erlangInstaller
▶ cd default

~/.erlangInstaller/default
▶ ls
Install       bin           erts-10.7.2.1 lib           misc          releases      usr

~/.erlangInstaller/default
▶ cd bin

.erlangInstaller/default/bin
▶ ls
ct_run             epmd               erlc               no_dot_erlang.boot start              start.script       start_erl          to_erl
dialyzer           erl                escript            run_erl            start.boot         start_clean.boot   start_sasl.boot    typer

.erlangInstaller/default/bin

I installed it and I can see it here.

It is a little off-topic but there is an age old way to install self compiled software into /usr/local in a clean way stow. It does not mung with environment variables. All it does is to swap out symlinks. I personally prefer it over nvm, rvm or asdf.

No idea about this :sweat_smile: Learning new stuff here now. Thanks

stow is old. most newer ways, including nvm, rvm do this:

  • install software in unconventional location
  • mung environment variable to point here

Stow does it differently:

  • install software in unconventional location
  • symlink all stuff into /usr/local, so you don’t need to mung environment variables

It is a matter of choice. I like the stow way, however please keep in mind that it does not work in certain environments, like if you don’t have root permission or on Windows.

1 Like

Why do we need Java Dependency for Erlang installation?