Akkoma compilation issues running under v3.8.0 with Elixir under asdf and user running under systemd

Based on an old script i have, the following should be what worked for me. If you got the correct versions already, you can probably skip to the Systemd part.

Set up Elixir and Erlang using asdf

with Akkoma user in home directory, sudo -u akkoma /bin/bash, do

touch $HOME/.tool-versions
"erlang 25.0" > $HOME/.tool-versions
"elixir 1.14.2" >> $HOME/.tool-versions
git clone --quiet https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.8.0 2>/dev/null
echo ". $HOME/.asdf/asdf.sh" >> "$HOME"/.bashrc
echo ". $HOME/.asdf/completions/asdf.bash" >> "$HOME"/.bashrc

source $HOME/.bashrc
asdf plugin-add erlang
asdf plugin-add elixir
asdf install

Now elixir --version ran as the Akkoma user should show that you have 1.14.2

Adapt Systemd service file

Systemd won’t have this in the PATH, and it uses the absolute path to the binary. So we need to adapt the service file. Assuming the HOME directory is /opt/akkoma

; This needs to be added
Environment="PATH=/opt/akkoma/.asdf/shims:/opt/akkoma/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
; This needs to be changed
ExecStart=/opt/akkoma/.asdf/shims/mix phx.server 

References

I got this from a script I wrote a long time ago.

1 Like