capistrano-puma: systemd: Neither a valid executable name nor an absolute path error because of ExecStart
Capistrano::Puma::Systemd is generating a systemd file for Puma with the below ExecStart value which uses the $HOME env var:
ExecStart=$HOME/.rbenv/bin/rbenv exec bundle exec puma -C /home/ubuntu/app/shared/puma.rb
This is causing the following error:
systemd/system/puma.service:9: Neither a valid executable name nor an absolute path: $HOME/.rbenv/bin/rbenv
service: Unit configuration has fatal error, unit will not be started.
Going through systemd’s manpage, it does say we need to use an absolute path for ExecStart: (https://man7.org/linux/man-pages/man5/systemd.service.5.html)
For each of the specified commands, the first argument must be either an absolute path...
Systemd version:
ubuntu@ip-172-31-86-176:/etc/systemd$ systemctl --version
systemd 245 (245.4-4ubuntu3.2)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid
Ubuntu version: Linux ip-172-31-86-176 5.4.0-1029-aws #30-Ubuntu SMP Tue Oct 20 10:06:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 15 (1 by maintainers)
Hi, I finally solved my issue by modifying the systemd unit file
/etc/systemd/system/puma_rasylva-web_production.servicemanually on my server. However, I think it’s a temporary solution, it may be better if the template can generate a more accurate systemd unit file.GENERATED BY TEMPLATE (lib/capistrano/templates/puma.service.erb):
MODIFIED:
Here are some notes of what makes it works and I think it may help others and improve capistrano-puma template:
rubycommandnoderelated commandERROR: No application configured, nothing to runappendcommand, it shows an error:Failed to parse output specifier, ignoring: append:/home/rasylva/apps/rasylva-web/current/log/puma.error.log. The alternative way is using stdout and stderr redirection:<THE_PUMA_COMMAND> > /home/rasylva/apps/rasylva-web/current/log/puma.access.log 2>/home/rasylva/apps/rasylva-web/current/log/puma.error.logFor debugging the systemd, it may also be helpful for others: https://containersolutions.github.io/runbooks/posts/linux/debug-systemd-service-units/
Try putting
set :rbenv_custom_path, "/home/ubuntu/.rbenv"into your deploy.rbThx to the @rizqirizqi I could fix the same problem using RVM too.
I just added the path to RVM instead of using the
~to solve it. I didn’t need to add environment or other thingsIn my case changing the
~/.rvmto/home/deployon line 9.