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.
- The part of setting up asdf: https://git.domainepublic.net/ilja/pleroma_ynh/-/blob/main/scripts/install#L88
- Template systemd service file (don’t copy it directly, it has placeholders, but should give a better idea on how the end result should look): https://git.domainepublic.net/ilja/pleroma_ynh/-/blob/main/conf/pleroma_asdf.service