Force RubyGems to use HTTP

為{幸葍}努か 提交于 2019-12-10 09:27:42

问题


I've been trying to workaround the fact that gem install is extremely slow on a 2.9GHz Intel Core 7 MacBook Pro.

I applied solutions I found on the internet:

https://stackoverflow.com/questions/1887704/gem-is-very-slow
http://buddingrubyist.wordpress.com/2009/02/14/how-to-speed-up-gem-installs-10x/

However they made no difference to me. A few posts including this one (ruby - bundle install/update too slow, first comment to user1189762's answer) says that RubyGems are slower when fetching from HTTPS.

This is my .gemrc:

---
gem: --no-ri --no-rdoc
benchmark: false
verbose: true
update_sources: true
sources:
- http://gems.rubyforge.org/
- http://rubygems.org/
backtrace: true
bulk_threshold: 1000

My sources are both using http, however if doing a verbose installation I get:

$ sudo gem install rack -V
Password:
GET https://rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
GET https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz
200 OK
GET https://rubygems.org/quick/Marshal.4.8/rack-1.5.2.gemspec.rz
302 Moved Temporarily
GET https://s3.amazonaws.com/production.s3.rubygems.org/quick/Marshal.4.8/rack-1.5.2.gemspec.rz
200 OK
Installing gem rack-1.5.2

All The requests are being made with https.

Anyway to force http in gemrc? Is that my bottleneck?


回答1:


The .gemrc is not applied because it lives in your user directory but when you execute the command with sudo the ownership of the execution is halted.

Either do not use sudo or use

$ sudo gem sources 

to manage the sources.

Usage: gem sources [options]

  Options:
    -a, --add SOURCE_URI             Add source
    -l, --list                       List sources
    -r, --remove SOURCE_URI          Remove source
    -c, --clear-all                  Remove all sources (clear the cache)
    -u, --update                     Update source cache

The command

$ sudo gem sources -c
$ sudo gem sources -a http://rubygems.org/

should change the source list.

Please keep in mind that if you are using rvm, bundler or rbenv, it's likely you don't need sudo to install your gems.



来源:https://stackoverflow.com/questions/20762369/force-rubygems-to-use-http

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!