How to remove a remote source from gem remote sources
I have added gemcutter.org to my Rubygems sources, and now I do not know how to remove it.
$ gem sources
*** CURRENT SOURCES ***
http://gemcutter.org
http://gems.rubyforge.org/
$ gem sources -r http://gemcutter.org
http://gemcutter.org removed from sources
$ gem sources
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
In general you can find the syntax with
gem help *command*
So this shows the options you needed:
gem help sources
But what if the problem is that the default source causes gem install to hang on non-connected systems? (You think it's impossible?!?) If you run the command provided by the most popular answer, and this happens:
# gem sources -r https://rubygems.org
source https://rubygems.org not present in cache
Then to deal with this situation, you must modify source cringe:
sed -i '/[[:space:]]def self\.default_sources/a return []' \
$RUBYGEMS_DIR/rubygems/defaults.rb
This adds a line of code, namely return []
to return an empty array, after the method that returns "default sources". Run gem environment
and you will see no nasty remote sources. Now you can go back and undo the sed command, or manually add the rubygems repo or whatever.
EDIT: Clarify, generalize.
精彩评论