Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-su: bundle: command not found when starting unicorn

I'm following a tutorial at DigitalOcean (fyi, this is the tutorials, link1 , link2 ), to install a production ready rails app using unicorn, and nginx, and when I get to the part on installing unicorn. When I try typing this into the console:

sudo service unicorn_appname start

I get this error:

Starting appname
-su: bundle: command not found

All users can bundle. This message makes no sense to me. Any ideas?

like image 992
Socks Avatar asked Feb 10 '23 09:02

Socks


1 Answers

I also followed the same guide and had the same issue.

The startup script in init.d/unicorn_appname is evaluated to:

su - deploy -c cd /home/deploy/appname && bundle exec unicorn -c config/unicorn.rb -E production -D

root user on startup will first su - into the rails user (in this case 'deploy') then excutes bundle to start up unicorn. rbenv is single user, only 'deploy' has bundle installed. The path to bundle is likely stored in your .bashrc file if you followed the guide. However .bashrc file which is not invoked by login in through su - and that caused the bundle not installed error.

The solution would be to include the paths related to rbenv in .profile. This way when root su - into 'deploy' the paths are loaded.

like image 103
zjwang Avatar answered Feb 12 '23 21:02

zjwang