Closed kellyselden closed 8 years ago
@kellyselden actually when you do runasuser internally one more file is executed get-forever-config, I think that is what is causing the issue. I will require some code changes in forever-service executable to execute get-forever-config with the correct node path. If you can send me a pull request I will be happy to accept it.
I don't think this is exclusively a runAsUser issue. I took it out and got the same error
sudo /home/vagrant/.nvm/versions/node/v5.1.0/bin/forever-service install taskrunner --foreverPath /home/vagrant/.nvm/versions/node/v5.1.0/bin --foreverOptions " -c /home/vagrant/.nvm/versions/node/v5.1.0/bin/node"
/usr/bin/env: node: No such file or directory
Have you tested just plain forever with nvm? Did it work?
Yes, that works because I don't have to run it with sudo. The problem I think is the nvm doesn't put anything in the root PATH.
Looks like issue is due to sudo running as a totally different environment (root), when you are executing forever or forever-service as non sudo, you might have already done nvm use specific version of node. And hence node executable is in the path. However when you run as sudo it is unable to find forever-service itself since in sudo no nodejs is in path.
I would recommend if you do want to use nvm, have only one version of nodejs for running services. And setup symlink to node executable for all global executables such as forever, forever-service
ln -s /home/vagrant/.nvm/versions/node/v5.1.0/bin/node /usr/bin/node
ln -s /home/vagrant/.nvm/versions/node/v5.1.0/bin/forever /usr/bin/forever
ln -s /home/vagrant/.nvm/versions/node/v5.1.0/bin/forever-service /usr/bin/forever-service
Once you have setup these you can run forever-service normally without getting into hassle of specifying complete path. And still use nvm to install modules without sudo.
@kellyselden did this work for you?
This worked. Thank you very much.
@arvind-agarwal @kellyselden Thanks for solving this issue. Solved my forever-service with local-npm problem.
sudo forever-service install local-npm-service --script /home/vagrant/.nvm/versions/node/v4.2.6/lib/node_modules/local-npm/lib/bin.js -o " -d /home/vagrant/.local-npm" --foreverPath /home/vagrant/.nvm/versions/node/v4.2.6/bin --start
Have you run across nvm user setup? My user path is
and my root path is
I've gotten this far after viewing #2:
but I still get
/usr/bin/env: node: No such file or directory
. It appears someone in the chain is still assuming node path for sudo.