most straightforward way to install Elixir 1.16 on stock ubuntu?

sudo apt-get install elixir will install elixir 1.12 for me. Could someone give the most straightforward way for me to install Elixir 1.16 which is required for my Phoenix installation?

The steps I tried with asdf have not been successful for me (I get a segfautl) so I would like to know what is the most standard, straightforward way. This is a stock Ubuntu installation on a recently spun-up AWS micro instance.

Thank you.

Never had problems with asdf. The concrete segfault (really?) would be interesting. Maybe you missed to install some prerequisites? This site explains the asdf elixir setup for ubuntu 18.04 (should be easy to adapt to current ubuntu): Using ASDF with Elixir and Phoenix (scroll down to " Install ASDF on Linux")

Copied this reply from what I assume is your reddit post:

If you want a one-liner, try this:

KERL_BUILD_DOCS=yes asdf install erlang 26.2.1 && asdf install elixir 1.16.0-otp-26 && asdf global elixir 1.16.0-otp-26

I just tried it, it gives the warning you mentioned, but still installs just fine on Ubuntu 23.04:

KERL_BUILD_DOCS=yes asdf install erlang 26.2.1 && asdf install elixir 1.16.0-otp-26
asdf_26.2.1 is not a kerl-managed Erlang/OTP installation
The asdf_26.2.1 build has been deleted
Extracting source code
Building Erlang/OTP 26.2.1 (asdf_26.2.1), please wait...
Building docs...
Erlang/OTP 26.2.1 (asdf_26.2.1) has been successfully built
Cleaning up compilation products for 26.2.1
Cleaned up compilation products for 26.2.1 under /home/tower/.asdf/plugins/erlang/kerl-home/builds
==> Checking whether specified Elixir release exists...
==> Downloading 1.16.0-otp-26 to /home/tower/.asdf/downloads/elixir/1.16.0-otp-26/elixir-precompiled-1.16.0-otp-26.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 7027k  100 7027k    0     0  6305k      0  0:00:01  0:00:01 --:--:-- 6314k
==> Copying release into place

After it builds, you should be able to run iex in the shell and start Elixir-ing.

If it’s taking a long time, it’s probably because the CPU in your AWS micro VPS is not very powerful. It takes a couple minutes to build on my computer with a decently powerful processor, so the command will probably take more than 10 minutes to finish executing.

If it doesn’t work, make sure you added this line to the end of your ~/.bashrc file:

. "$HOME/.asdf/asdf.sh"

To @fpauserfpauser:

You write:

Never had problems with asdf. The concrete segfault (really?) would be interesting

This is the concrete segfault:

ubuntu@ip-[ip]:~$ elixir -v
{"init terminating in do_boot",{undef,[{elixir,start_cli,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({undef,[{elixir,start_cli,[],[]},{init,start_em,1,[]},{init,do_boot,3,[]}]})

Crash dump is being written to: erl_crash.dump...done
ubuntu@ip- [ip]  :~$
ubuntu@ip- [ip]  :~$ asdf list elixir
 *1.16.0-otp-26
ubuntu@ip [ip]  :~$ asdf install elixir latest
elixir 1.16.0-otp-26 is already installed

I will take a look at " Using ASDF with Elixir and Phoenix " that you linked.

To @arcanemachine
Thank you, for me this is what posting your one-liner which you posted as
KERL_BUILD_DOCS=yes asdf install erlang 26.2.1 && asdf install elixir 1.16.0-otp-26 && asdf global elixir 1.16.0-otp-26

gives:

ubuntu@ip-[IP]:~$ KERL_BUILD_DOCS=yes asdf install erlang 26.2.1 && asdf install elixir 1.16.0-otp-26 && asdf global elixir 1.16.0-otp-26
asdf_26.2.1 is not a kerl-managed Erlang/OTP installation
No build named asdf_26.2.1
Downloading 26.2.1 to /home/ubuntu/.asdf/downloads/erlang/26.2.1...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  101M  100  101M    0     0  88.2M      0  0:00:01  0:00:01 --:--:--  129M
Extracting source code
Building Erlang/OTP 26.2.1 (asdf_26.2.1), please wait...
[packages] Probe failed for libssl-dev (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "libssl-dev" 2>/dev/null | \grep -q '^i'" returned 1
[packages] Probe failed for make (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "make" 2>/dev/null | \grep -q '^i'" returned 1
[packages] Probe failed for automake (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "automake" 2>/dev/null | \grep -q '^i'" returned 1
[packages] Probe failed for autoconf (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "autoconf" 2>/dev/null | \grep -q '^i'" returned 1
[packages] Probe failed for libncurses5-dev (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "libncurses5-dev" 2>/dev/null | \grep -q '^i'" returned 1
[packages] Probe failed for gcc (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "gcc" 2>/dev/null | \grep -q '^i'" returned 1
[packages] Probe failed for g++ (distro: ubuntu): probe "dpkg-query -Wf'${db:Status-abbrev}' "g++" 2>/dev/null | \grep -q '^i'" returned 1
Configure failed.
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
configure: error: in `/home/ubuntu/.asdf/plugins/erlang/kerl-home/builds/asdf_26.2.1/otp_src_26.2.1/erts':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
ERROR: /home/ubuntu/.asdf/plugins/erlang/kerl-home/builds/asdf_26.2.1/otp_src_26.2.1/erts/configure failed!
./configure: 370: kill: No such process


Please see /home/ubuntu/.asdf/plugins/erlang/kerl-home/builds/asdf_26.2.1/otp_build_26.2.1.log for full details.

As I mentioned this is a stock build of Ubuntu (in fact it is Amazon’s stock build) freshly spun up so I can see it is missing large parts of the toolchain (I can see in the lines above the errors about missing gcc etc), hence I would like to know what single line to paste.

I am trying to move toward the containerization mindset which is why I would like to be able to get it down to a single line, so I can later put it in a Docker file for it!

This error usually indicates that the versions of parts of the BEAM and the Elixir runtime disagree. A similar failure from an older version:

asdf-erlang requires build-essential, amongst other things, before it can be installed.


You might find the official Elixir images useful, either as a one-line source or as a reference.

3 Likes

Just for anyone else searching, in the end I found that getting it from Docker Hub for my version of Ubuntu is the most straightforward solution.

So, on Ubuntu I typed lsb_release -a which showed me that I am on Jammy and I got the corresponding image based on the tags for that OS at at Docker

In my case this consists of pulling the image with docker pull hexpm/elixir:1.16.0-erlang-24.3.4.15-ubuntu-jammy-20231004.

It’s the most straightforward way to make sure it works for me.

If for some reason asdf isn’t working, you can take a look at the Ubuntu packages of Elixir and Erlang provided by Erlang Solutions: Erlang and Elixir Packages Download - Erlang Solutions

Stock ubuntu does not come with c compiler, so you probably need to install it (and a bunch of other deps, most of them will be in the build-essential package, but not all) because the erlang plugin from asdf compiles it from the source.

That said, unless you’re using the micro instance for development I would seriously recommend that you use releases instead of running the code directly using the interpreter.

2 Likes

This lists the prerequisites for Erlang.

2 Likes