Gem macOS Mojave /Library/Ruby/Gems 下有多个版本的目录,是否可以安全删除?

zyqhi · 2018年11月30日 · 最后由 luikore 回复于 2018年12月03日 · 6435 次阅读

请问社区里面的大大,我这种情况该如何解决?问题是这样的:

我现在的系统 /Library/Ruby/Gems 目录下有两个版本的 gems 目录,分别为 2.0.0,2.3.0,但是从 gem list 命令来看,只有 2.3.0 下面的是有效的,现在我想直接删除 2.0.0 下面的 gems,但是不知道直接删除是否安全,所以求助大家。我磁盘空间有限,想清理一下。

我试过 gem cleanup,没有任何效果,输出如下:

➜  Gems gem cleanup
Cleaning up installed gems...
Clean up complete

gem 的相关环境信息:

➜  Gems pwd
/Library/Ruby/Gems
➜  Gems ls -l
total 0
drwxr-xr-x  7 root  wheel  224 Sep 25 13:31 2.0.0
drwxr-xr-x  8 root  wheel  256 Aug 18 06:59 2.3.0

➜  Gems ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
➜  Gems which ruby
/usr/bin/ruby

➜  Gems gem environment
RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.7
  - RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
  - USER INSTALLATION DIRECTORY: /Users/mutsu/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /Users/mutsu/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-18
  - GEM PATHS:
     - /Library/Ruby/Gems/2.3.0
     - /Users/mutsu/.gem/ruby/2.3.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://gems.ruby-china.com"]
  - REMOTE SOURCES:
     - https://gems.ruby-china.com
  - SHELL PATH:
     - /usr/local/opt/curl/bin
     - /usr/local/opt/openssl/bin
     - /Users/mutsu/bin
     - /usr/local/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin

gem list 命令只列出了 /Library/Ruby/Gems/2.3.0下面的gems,

➜  Gems gem list

*** LOCAL GEMS ***

activesupport (4.2.11)
atomos (0.1.3)
bigdecimal (default: 1.2.8)
CFPropertyList (3.0.0, 2.2.8)
claide (1.0.2)
cocoapods (1.5.3)
cocoapods-core (1.5.3)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.3.1)
cocoapods-try (1.1.0)
colored2 (3.1.2)
concurrent-ruby (1.1.3)
did_you_mean (1.0.0)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
i18n (0.9.5)
io-console (default: 0.4.5)
json (default: 1.8.3.1)
libxml-ruby (2.9.0)
minitest (5.8.5)
molinillo (0.6.6)
nanaimo (0.2.6)
nap (1.1.0)
net-telnet (0.1.1)
netrc (0.11.0)
nokogiri (1.5.6)
power_assert (0.2.6)
psych (default: 2.1.0.1)
rake (10.4.2)
rdoc (default: 4.2.1)
rouge (2.0.7)
ruby-macho (1.3.1)
rubygems-update (2.7.7)
sqlite3 (1.3.11)
test-unit (3.1.5)
thread_safe (0.3.6)
tzinfo (1.2.5)
xcodeproj (1.7.0)
xcpretty (0.3.0)

2.3.0 目录下面的已安装 gems

➜  Gems ls 2.3.0/gems
CFPropertyList-3.0.0        cocoapods-downloader-1.2.2  concurrent-ruby-1.1.3       minitest-5.8.5              rake-10.4.2                 tzinfo-1.2.5
activesupport-4.2.11        cocoapods-plugins-1.0.0     did_you_mean-1.0.0          molinillo-0.6.6             rdoc-4.2.1                  xcodeproj-1.7.0
atomos-0.1.3                cocoapods-search-1.0.0      escape-0.0.4                nanaimo-0.2.6               rouge-2.0.7                 xcpretty-0.3.0
claide-1.0.2                cocoapods-stats-1.0.0       fourflusher-2.0.1           nap-1.1.0                   ruby-macho-1.3.1
cocoapods-1.5.3             cocoapods-trunk-1.3.1       fuzzy_match-2.0.4           net-telnet-0.1.1            rubygems-update-2.7.7
cocoapods-core-1.5.3        cocoapods-try-1.1.0         gh_inspector-1.1.3          netrc-0.11.0                test-unit-3.1.5
cocoapods-deintegrate-1.0.2 colored2-3.1.2              i18n-0.9.5                  power_assert-0.2.6          thread_safe-0.3.6

2.0.0 目录下面的已安装 gems

➜  Gems ls 2.0.0/gems
RedCloth-4.2.9                     cocoapods-downloader-1.1.0         execjs-2.4.0                       liquid-2.6.2                       redcarpet-3.2.2
activesupport-4.2.1                cocoapods-plugins-0.4.2            fast-stemmer-1.0.2                 listen-2.9.0                       rouge-1.11.1
addressable-2.3.7                  cocoapods-plugins-1.0.0            fastimage-1.6.8                    mercenary-0.3.5                    rubygems-update-2.5.1
blankslate-2.1.2.4                 cocoapods-plugins-1.0.0.beta.1     ffi-1.9.8                          mini_portile-0.6.2                 rubygems-update-2.6.7
bundler-1.9.1                      cocoapods-search-0.1.0             fourflusher-0.3.2                  minitest-5.5.1                     safe_yaml-1.0.4
celluloid-0.16.0                   cocoapods-search-1.0.0             fui-0.4.0                          molinillo-0.3.1                    sass-3.4.13
claide-0.9.1                       cocoapods-search-1.0.0.beta.1      fuzzy_match-2.0.4                  molinillo-0.4.1                    term-ansicolor-1.3.2
claide-1.0.0                       cocoapods-stats-0.5.3              gemoji-2.1.0                       molinillo-0.4.5                    thor-0.19.1
claide-1.0.0.beta.1                cocoapods-stats-0.6.2              github-pages-health-check-0.2.2    nap-0.8.0                          thread_safe-0.3.5
classifier-reborn-2.0.3            cocoapods-stats-1.0.0              gli-2.14.0                         nap-1.0.0                          timers-4.0.1
cocoa-0.1.6                        cocoapods-stats-1.0.0.beta.3       hitimes-1.2.2                      net-dns-0.8.0                      tins-1.12.0
cocoapods-0.38.0                   cocoapods-trunk-0.6.4              i18n-0.7.0                         netrc-0.7.8                        toml-0.1.2
cocoapods-0.38.2                   cocoapods-trunk-1.0.0              inquirer-0.2.1                     nokogiri-1.6.6.2                   tzinfo-1.2.2
cocoapods-1.0.0                    cocoapods-trunk-1.0.0.beta.1       jekyll-2.4.0                       parslet-1.5.0                      update_xcode_plugins-0.3.1
cocoapods-1.0.1                    cocoapods-try-0.4.5                jekyll-2.5.3                       pods-0.0.1                         update_xcode_plugins-0.3.2
cocoapods-core-0.38.0              cocoapods-try-0.5.1                jekyll-coffeescript-1.0.1          posix-spawn-0.3.10                 xcodeproj-0.26.3
cocoapods-core-0.38.2              cocoapods-try-1.0.0.beta.2         jekyll-gist-1.2.1                  public_suffix-1.4.6                xcodeproj-0.28.2
cocoapods-core-0.39.0              cocoapods-try-1.1.0                jekyll-paginate-1.1.0              pygments.rb-0.6.1                  xcodeproj-1.0.0.beta.2
cocoapods-core-1.0.0               coffee-script-2.3.0                jekyll-sass-converter-1.2.0        pygments.rb-0.6.2                  xcodeproj-1.2.0
cocoapods-core-1.0.0.beta.2        coffee-script-source-1.9.1         jekyll-sass-converter-1.3.0        rack-1.6.5                         xcpretty-0.2.4
cocoapods-core-1.0.1               colorator-0.1                      jekyll-watch-1.2.1                 rack-http-logger-0.1.0             yajl-ruby-1.2.1
cocoapods-deintegrate-1.0.0        colored-1.2                        json-1.8.2                         rake-10.4.2
cocoapods-deintegrate-1.0.0.beta.1 colorize-0.8.1                     kramdown-1.5.0                     rb-fsevent-0.9.4
cocoapods-downloader-0.9.3         earlgrey-0.0.8                     kramdown-1.6.0                     rb-inotify-0.9.5
cocoapods-downloader-1.0.0.beta.1  escape-0.0.4                       liquid-2.6.1                       redcarpet-3.1.2

/usr/bin/ruby -v ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

10.14 好像升级到 2.3,但是也很落后了。。。

pynix 回复

是的,不知道老的版本残留能不能直接清掉

可以直接删掉,一般 /System/Library/Frameworks/Ruby.framework/Versions 也不留老的,那这些 gem 也没用了

需要 登录 后方可回复, 如果你还没有账号请 注册新账号