Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executable path is not absolute, ignoring: $(which node)

The idea is to use a variable pointing to node instead of hardcoded path, my solution was this ExecStart="$(which node)" /home/jonma/Development/chewy

But when I run the service I get the following error:

feb 08 11:12:51 jonma-VirtualBox systemd[1]: [/lib/systemd/system/chewy.service:2] Executable path is not absolute, ignoring: $(which node) /home/jon
feb 08 11:12:51 jonma-VirtualBox systemd[1]: chewy.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

How can I achieve this without hardcoding the path?

like image 395
JonB Avatar asked Feb 08 '18 11:02

JonB


1 Answers

systemd will not accept commands that are not given with absolute path, so to accomplish what you want you need rely on bash-ism and do one of the following:

ExecStart=/bin/bash -c '$$(which node) /home/jonma/Development/chewy'

or

ExecStart=/bin/bash -c '`which node` /home/jonma/Development/chewy'

(i like the first one better, but you can do any)

like image 152
aleivag Avatar answered Nov 09 '22 17:11

aleivag