0

I'm using Debian Linux, Ruby on Rails 5 on Apache with Passenger. I crated the file ~/.gemrc

gem: --no-rdoc --no-ri

However, I'm running the command

sudo bundle install

and it doesn't seem to be picking up the above. How do I get "sudo" to recognize my "~/.gemrc" file?

ps - I have to run with sudo b/c the Apache directory from where I'm running this command complains about bad permissions if I don't do this.

  • It's better to set the right permissions to your apache directory rather than blindly using sudo. But if you want to go this way you have to copy the .gemrc file in the home directory of root which is /root. – Ortomala Lokni Sep 14 '17 at 15:52
0

Nowadays sudo switches your user to root, and in Debian it defaults to rewriting your $HOME, so it becames /root:

$ sudo sh -c 'echo $HOME'
/root

So, $HOME/.gemrc under root is expected to be in /root/.gemrc, and chances are that you want it to pick up a file from your regular user's directory.

The blunt force solution is to do something like

sudo ln -s /home/your_user_name/.gemrc /root/.gemrc

A little more intricate solution is either to disable always_set_home in /etc/sudoers.

Another option is to use somewhat complicated way to call sudo like

sudo sh -c 'export HOME=/home/your_user_name; bundle install'
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.