如何删除默认宝石?!想卸载一个gem 1.7.7版本的json [英] How can I remove a default gem? ! want to uninstall a gem 1.7.7 version of json
问题描述
我在 OSX 和 Ubuntu 中有相同的 rails 应用程序,我想使用 Zeus 来加速我的 rspec.在 Ubuntu 中,Zeus 启动正常,但在 OSX 中它总是崩溃.最后我找到了问题,https://github.com/burke/zeus/issues/237#issuecomment-18700462 OSX 和 Ubuntu 的区别在于 json gem 的版本.我使用 gem list |grep json
Ubuntu 显示
I have the same rails app in OSX and Ubuntu, I want to use Zeus to speed up my rspec.
In Ubuntu, Zeus starts Ok, but in OSX it always be crashed.
At last I find the issue, https://github.com/burke/zeus/issues/237#issuecomment-18700462 the difference between OSX and Ubuntu is the version of json gem.
I use gem list | grep json
Ubuntu shows
json (1.8.1, 1.8.0, 1.5.3)
json_pure (1.5.3)
json_spec (1.1.1)
jsonpath (0.5.3)
multi_json (1.8.2, 1.7.8, 1.0.3)
Mac 显示
json (1.8.1, 1.7.7)
json_spec (1.1.1)
jsonpath (0.5.5, 0.5.3)
multi_json (1.8.2, 1.7.8)
所以想卸载1.7.7版本的json gem让zeus启动,但是
so I want to uninstall 1.7.7 version of json gem to make zeus start, but
gem uninstall json -v 1.7.7
ERROR: While executing gem ... (Gem::InstallError)
gem "json" cannot be uninstalled because it is a default gem
我该怎么办?
推荐答案
因此,据我所知,没有简单的命令可以将 gemspec 文件从默认文件夹移动到非默认文件夹.据我所知,这是一件好事,但这里有关于如何手动执行此操作的说明.
So based off what I can tell there is no easy command that can move the gemspec file from the default folder to the non-default folder. This is a good thing from what I can tell but here are the instructions on how to do this by hand.
找到默认规范的位置.最简单的方法是进入
irb
并运行以下命令:
irb(main):002:0> Gem.default_specifications_dir
=> "/Users/user/.rubies/ruby-2.5.7/lib/ruby/gems/2.5.0/specifications/default"
对于较旧的红宝石,它是:
For older rubygems it's:
irb(main):001:0> File.join Gem::Specification.default_specifications_dir
=> "/Users/newdark/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/specifications/default"
这是构建 gemspec 路径的代码行https://github.com/rubygems/rubygems/blob/v2.6.13/lib/rubygems/installer.rb#L420
This is the line of code that builds the gemspec path https://github.com/rubygems/rubygems/blob/v2.6.13/lib/rubygems/installer.rb#L420
获得文件路径后,只需将 gem 名称和版本从默认文件夹移动到父文件夹即可.
Once you get the file path you just need to move the gem name and version from the default folder to the parent folder.
$ cd /Users/newdark/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/specifications/default
$ mv json-1.7.7.gemspec ../
如果您执行 gem list -d
,您应该不会再看到 gem 版本 json-1.7.7 旁边的字词 Installed at (default)
.然后,您可以运行 gem uninstall json -v 1.7.7
而不会与您发生冲突.如果你想撤销这一切,只需运行 gem install json -v 1.7.7 --default
if you do gem list -d
you should no longer see the words Installed at (default)
next to the gem version json-1.7.7. you can then run gem uninstall json -v 1.7.7
with out it fighting you. If you want to undo all this just run gem install json -v 1.7.7 --default
这篇关于如何删除默认宝石?!想卸载一个gem 1.7.7版本的json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!