When deploying yarn command not found, but via ssh yarn works fine
I recently switched to linuxbrew on my staging environment, for easier management of packages like node and yarn. However, Im experiencing a weird issue when deploying. To compile assets in my project I use yarn. But the deployments keep failing because the yarn command is not known.
So I ssh'd into my machine with the user forge and ran "sh /home/forge/.forge/provision-18859488.sh"(which is being showed in the deployment log) and the script runs perfectly fine including yarn.
As far as I know deployments are being run using the forge user as well. This makes me wonder why the deployment script (when executed via forge.laravel.com) does not know the yarn command.
I also tried rebooting the machine and added export PATH="$PATH:yarn global bin" to .bash_profile to make yarn globally available. But it had no effect.
Does anybody know what else I could try to troubleshoot this issue?
It about someone that is experiencing a similar problem. So it seems that .bash_profile doesn't apply for the user forge for deployments. It uses /etc/environment. So as suggested in the post I fixed my problem by adding linuxbrew path to /etc/environment.
So my path in /etc/environment looks like: "PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin"
I saved the file and boom, ran deployment and it worked straight away. The only thing I'm sure of, is if this would affect security in any way. That's something I would look into further. Anyways, managing node npm and yarn has become a lot easier now.