通过运行“gemsources-c”我实际上删除了什么?

Bry*_*cke 5 ruby rubygems

我运行了“ gem sources -c”,这样我就必须特意指定要从哪里安装 gem,因为我现在有 3 个不同的 gem 安装源 - RubyForge、Github 和 Gemcutter。

C:\>gem sources -c
*** Removed specs cache ***
*** Removed user source cache ***
*** Removed latest user source cache ***
*** Removed system source cache ***
*** Removed latest system source cache ***
Run Code Online (Sandbox Code Playgroud)

运行此命令后,我再次运行gem sources以确保我不再有任何默认源,我得到以下信息:

C:\>gem sources
*** CURRENT SOURCES ***

http://gems.rubyforge.org
http://gems.github.com
http://gems.rubyforge.org/
http://gemcutter.org
Run Code Online (Sandbox Code Playgroud)

换句话说,一切都没有改变

查看gem sources -c下面的帮助,这似乎是一次删除所有宝石源的正确命令:

    -c, --clear-all                  Remove all sources (clear the cache)
Run Code Online (Sandbox Code Playgroud)

不然的话,看来你得把它们一一删除了。没什么大不了的,因为我只有 4 个,但我想知道我实际上通过执行“ gem sources -c删除了什么。

C:\>gem sources --help
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

  Local/Remote Options:
    -p, --[no-]http-proxy [URL]      Use HTTP proxy for remote operations

  Common Options:
    -h, --help                       Get help on this command
    -V, --[no-]verbose               Set the verbose level of output
    -q, --quiet                      Silence commands
        --config-file FILE           Use this config file instead of default
        --backtrace                  Show stack backtrace on errors
        --debug                      Turn on Ruby debugging
Run Code Online (Sandbox Code Playgroud)

小智 2

对于每个源,rubygems 都会保留有关每个源托管的 gem 的信息的本地缓存,以加快操作速度,并且该命令只会清除这些缓存。

查看 ruby​​gems 源代码,在我的系统上,它删除了

C:/Users/Kris/.gem/specs
C:/Users/Kris/.gem/source_cache
C:/Users/Kris/.gem/latest_source_cache
C:/Ruby/lib/ruby/gems/1.8/source_cache
C:/Ruby/lib/ruby/gems/1.8/latest_source_cache
Run Code Online (Sandbox Code Playgroud)

您仍然需要自己删除实际的来源。