Problem with Bundle Install - Rails on Ubuntu

Posted December 18, 2014 25.8k views

I have a problem with bundle install. I have a fresh droplet with Rails and Ubuntu. If I run as root:

bundle install

I get the following message and my application breaks, start getting “Bad Gateway” errors from Nginx:

Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.

If I run bundle install as the rails user:

su rails
bundle install

then I get this error:

sh: 1: bundle: not found

What am I missing? I’ve scoured the internet and tried every solution I can find and can’t get it working quite right.

Thanks for your help,

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

The ruby installation on the Rail on Rails One-Click application is managed by RVM. If you run which bundle you can see that the binary is installed to:

# which bundle

The rails user doesn’t have a login shell, so you’d need to manually source the file /etc/profile.d/ to access the Ruby installation.

You can set a proper login shell for the rails user by running:

chsh -s /bin/bash rails

Then switch to the user with: su - rails From man su

  -, -l, --login
     Provide an environment similar to what the user would expect had the user logged in directly.

For more info on the One-Click application, check out:

by Justin Ellingwood
Ruby on Rails is one of the most popular application stacks available in order to get your app or website up and running quickly. In this guide, we'll discuss how to install Ruby on Rails on an Ubuntu 14.04 VPS instance using the RVM utility.