I am required to run the following Ubuntu bash script as "sudo" (FYI, this is because I am running it through Upstart):
cd /u/apps/MyRailsApp/current && /usr/bin/env RAILS_ENV=production script/delayed_job restart >> /var/log/upstart/delayed_job.log
However, when I run it as "sudo", I get the following error:
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/source/git.rb:188:in rescue in load_spec_files': [email protected]:MyRemoteRepo/my_gem.git (at 1.0.1) is not yet checked out. Run
bundle install` first. (Bundler::GitError)
It's not recommended to run "bundle install" as Sudo. When I run "bundle install" as a non-admin user, it is working and all the gems are recognized. How do I get the root user to recognize the gem?
The gem is in /home/ubuntu/.bundler/ruby/1.9.1/. My other gems are in /var/lib/gems/1.9.1/gems/
Thanks so much for your help.
Try adding "source /home/[username]/.bashrc" where [username] is non-admin user that can run the script successfully.