1-Click RoR installation: how is 'rails' user supposed to install gems?

This is my first time using a 1-Click droplet with Ubuntu and Ruby on Rails.

I logged into the droplet as the rails user and tried to add Devise to the preinstalled rails app, but got a permissions error when running bundle install. Similarly, if I try something like gem install nokogiri, I get an error saying that I don’t have write permissions to the the /usr/local/rvm/gems/ruby… directory.

What is the normal way to add gems to the rails app? I assume not by becoming root, right?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

OK, I succeeded in running bundle install as the rails user (no sudo).

As the rvm documentation said, non-root users can install gems as needed in the system-wide Ruby if they are members of the rvm group. All you have to do is, as root, execute this command:

gpasswd -a rails rvm

After that, everything should work. The reason I was getting errors after that was that I am using the smallest droplet size and it was running out of memory. I created a temporary swap file (see this article for information about how to do that) and everything worked without problems.

Good to hear you got it working. Using my ipad now but will check it out when im back home. Good luck with your ruby app

Hi CrypticDesigns,

Thanks for your answer, but the droplet’s Ruby installation uses rvm, which specifically warns against sudo for things like installing gems. It is designed to work without having to do that, and doing it is a security risk.

Looking at the rvm documentation, I think that what is needed is to make the rails user a member of the rvm group. I am trying that now, but now I am getting other errors, probably because some library bundle depends on is not installed.

If I succeed in doing this, I will post an update to this question.