How to programmatically add http://rubygems.org as a source of gems?

The corporate proxy at my company seems to interfere with httpsconnections to rubygems.org connections (but not http), causing crashes when trying to set gems from the default gem source, https://rubygems.org . For this reason, I am trying to update my gem sources to replace the default source with an unsecured version of rubygems.org http. (And yes, I know the security implications of this.)

When I do this manually from the command line, everything works fine; I just need to go through the warning message:

$ gem sources --add http://rubygems.org
https://rubygems.org is recommended for security over http://rubygems.org

Do you want to add this insecure source? [yn]

However, there seems to be no way around this prompt when running this command from an automated script. The command gemhas no option --yesor --force(as far as I know) and is trying to use yesto skip the prompt, it simply leads to the following error message:

$ yes | gem sources --add http://rubygems.org
ERROR:  While executing gem ... (Gem::OperationNotSupportedError)
    Not connected to a tty and no default specified

How can I go through a warning message to programmatically add http://rubygems.org as a source?

+4
source share
1 answer

To remove https sources:

gem sources -r https://rubygems.org/

If you put the following in ~ / .gemrc, it will pick it up in gem env

---
:backtrace: false
:bulk_threshold: 1000
:sources: ["http://rubygems.org"]
:update_sources: true
:verbose: true

gem env snippet:

 - GEM CONFIGURATION:
    - :update_sources => true
    - :verbose => true
    - :backtrace => false
    - :bulk_threshold => 1000
    - :sources => ["http://rubygems.org"]
 - REMOTE SOURCES:
    - http://rubygems.org
+6
source

All Articles