当我从我的主目录(而非项目)运行gem list
时,我得到了一系列我在Mac上安装的宝石。然而,似乎有很多不同版本的宝石,我知道我不需要,像这样:
本地宝石
actionpack (4.2.6, 4.2.4, 4.2.2)
actionview (4.2.6, 4.2.4, 4.2.2)
activemodel (4.2.6, 4.2.4, 4.2.2)
activesupport (4.2.6, 4.2.4, 4.2.2)
bigdecimal (1.2.7, default: 1.2.6)
io-console (0.4.6, default: 0.4.3)
json (1.8.3, default: 1.8.1)
mini_portile2 (2.1.0, 2.0.0)
minitest (5.9.0, 5.8.4)
psych (2.0.17, default: 2.0.8)
rails-dom-testing (2.0.0, 1.0.7)
rake (11.1.2, default: 10.4.2)
rdoc (4.2.2, default: 4.2.0)
slop (4.3.0, 3.6.0)
uglifier (3.0.0, 2.5.3)
安装了相同gem的两个(甚至三个)不同版本。我猜这可能是某些宝石,比如Rake,使用旧版本作为默认版本。
如何摆脱这些过时的gem版本,以及如何设置较新的版本(例如bigdecimal
,io-console
,rake
等)作为默认版本宝石?
答案 0 :(得分:3)
您可以通过输入
从计算机中全局删除宝石gem uninstall <gem_name> --version x.x.x
#Removes particular version of the gem
gem cleanup <gem_name>
#will remove all versions except the latest
但是,拥有不同版本并不坏,除非你认为它们已经过时并且永远不会被再次使用。
要使用特定版本的gem,我认为Gemfile.lock是最好的方法。或者你可以参考这个link。它显示了与您类似的问题。