bash: command not found
When running a pre or post-deployment SSH command on your server during a deployment, you may run into an error like the following:
bash: tool: command not found
Where tool
is the name of the tool you're trying to use. For example, something like Composer.
This can happen as a result of a mismatch in paths. DeployHQ when connecting does so non-interactively (i.e. as a non-human user), which is different from when you connect via your terminal using an interactive (human) connection. This then explains why the command works perfectly fine when you run it directly.
You should check that your user's ~/.bashrc
and ~/.bash_profile
files contain the same paths so that both connection types can correctly access the tool you're using.
This FAQ also provides further information about the differences between running an interactive or non-interactive session.
Testing commands non-interactively
If you need to run a non-interactive connection test to verify that your commands are working correctly, you can connect to your server from a terminal and append -t
to the connection string, along with the command you wish to run.
$ ssh user@server.com -t "your command here"
Just replace your command here
with the actual command you wish to run, keeping the "" quotes in place. A connection to the server will then be established, the command will run then the connection will immediately close, with the output of the command displayed inline.
$ ssh root@185.199.223.156 -t "time"
real 0m0.000s
user 0m0.000s
sys 0m0.000s
Connection to 185.199.223.156 closed.