Stop asking for a password when setting gems

Whenever I connect my rails with 3.2 stones, he asks me for my password:

Enter your password to install the included RubyGems on your system.

This becomes very annoying, especially when it is combined several times in one project. However, when I install the gem directory in a readable world, it always gives me a warning when executing any (!) Rails command. This is even more annoying, of course.

How to disable this?

+4
source share
5 answers

It is absolutely connected with the system ruby, and not with RVM, if you did not install RVM using the Multi-User installation type. If you did this and still ask for your password, then you installed as root , strictly against what is indicated in the specified documentation , and your general user was not added to the 'rvm' created by the installer. (NOTE: This is based on the idea that you want to install a multi-user system, not one user. If you want one user to install, not the sudo prefix, when the installer starts.)

Remove the RVM, log off, then return (to ensure a completely fresh reinitialization of the environment), and then run the installer command as a normal user and not as root , with the prefix 'sudo' as indicated in the documentation.

If you do not have RVM installed, follow the documentation at https://rvm.io to install either as a single user installation or as a multi-user installation. In this case, if RVM is not installed, then the Billy Chan described above is your fix, although I would suggest tightening the rules a bit to find out which set of commands (bunker names) you need to run on a regular basis and add entries for those in the sudoers (visudo) file.

Currently, the problem is that you are trying to use a system ruby ​​that * RVM does NOT (it just allows you to access it by setting the correct environment variables GEM_PATH, RUBY_ *, etc.) or your multi-user RVM installation was performed incorrectly.

+3
source
# install gem with the specified path bundle install --path vendor/bundle 
+10
source

Best method: use RVM. With RVM, you can simply run gem <any command> without adding sudo

If you do not want to use RVM, you can add sudo before the commands. And you can set sudo ask for a password for all commands:

  $ sudo EDITOR=vim visudo # or any editor in your system 

Then edit the document by adding the following line

  username ALL=(ALL) NOPASSWD: ALL # Where username must be replaced by your real username in system 

I know that this is not so safe, but convenient to use on my machine.

You can use these two methods together, like me.

0
source

It depends on whether you want to install gems under the system or under your user. If under your current user, you can simply turn on this message and request the switch configuration.

In your project, in the .bundle/config file add the line

 BUNDLE_DISABLE_SHARED_GEMS: '1' 

Thus, the entire configuration file may look like

 --- BUNDLE_WITHOUT: development:test BUNDLE_DISABLE_SHARED_GEMS: '1' BUNDLE_PATH: /home/youruser/gems/ 
0
source

I have a problem installing rails. A quick workaround for this is to skip package installation during project creation like this:

 rails new webapp -B 

And then you can do:

 cd webapp/ mkdir -p vendor/bundle bundle install --path vendor/bundle 

Hope this helps future requests.

0
source

All Articles