Take the 2-minute tour ×  I'm having some trouble with an
upstart script of ours that changes user and starts up a few
ruby daemon processes.  In the past i would simply bash -c "do
the business" -l someuser making sure to use the -l flag to
emulate a login.  This has worked great until now, our ruby
process has been throwing the following error: require: no such
file to load -- rubygems (LoadError) after some investigation I
found this error only occurs when I run the script as the root
user, i.e. (when I sudo su or when being run by upstart).  I
think this is a PATH issue as when I manually set the path first
it resolves the issue.  Is there a way to change user and load
the entire environment?  I have also tried su user -c and sudo.
To make it easier to test I'm "rooting up" (sudo su) and running
which bundle (bundle is a ruby thing).  Here's what I get:    •
sudo -i -u webuser which bundle # => no output   • su -l webuser
-c which bundle # => no output   • sudo su - webuser -c which
bundle # => no output