By ekortright
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?
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!
You probably got some basic sudo permissions error. Try to use the following instead:
sudo bundle install
and
sudo gem install nokogiri
Think this will work for you.
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.
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.