[英]How can I remove a default gem? ! want to uninstall a gem 1.7.7 version of json
I have the same rails app in OSX and Ubuntu, I want to use Zeus to speed up my rspec.我在 OSX 和 Ubuntu 中有相同的 rails 应用程序,我想使用 Zeus 来加速我的 rspec。 In Ubuntu, Zeus starts Ok, but in OSX it always be crashed.
在 Ubuntu 中,Zeus 启动正常,但在 OSX 中它总是崩溃。 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.
最后我找到了问题, https://github.com/burke/zeus/issues/237#issuecomment-18700462 OSX和Ubuntu之间的区别是json gem的版本。 I use
gem list | grep json
我使用
gem list | grep json
gem list | grep json
Ubuntu shows gem list | grep json
Ubuntu 显示
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 shows 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)
so I want to uninstall 1.7.7 version of json gem to make zeus start, but所以我想卸载 1.7.7 版本的 json gem 让 zeus 启动,但是
gem uninstall json -v 1.7.7
ERROR: While executing gem ... (Gem::InstallError)
gem "json" cannot be uninstalled because it is a default gem
What should I do?我应该怎么办?
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.因此,根据我所知道的,没有简单的命令可以将 gemspec 文件从默认文件夹移动到非默认文件夹。 This is a good thing from what I can tell but here are the instructions on how to do this by hand.
据我所知,这是一件好事,但这里有关于如何手动执行此操作的说明。
Find the location of the default spec.查找默认规范的位置。 The easiest way is to go into
irb
and run the following command:最简单的方法是进入
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"
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这是构建 gemspec 路径的代码行https://github.com/rubygems/rubygems/blob/v2.6.13/lib/rubygems/installer.rb#L420
Once you get the file path you just need to move the gem name and version from the default folder to the parent folder.获得文件路径后,您只需将 gem 名称和版本从默认文件夹移动到父文件夹。
$ cd /Users/newdark/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/specifications/default $ mv json-1.7.7.gemspec ../
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.如果您执行
gem list -d
,您应该不会再在 gem 版本 json-1.7.7 旁边看到Installed at (default)
字样。 you can then run gem uninstall json -v 1.7.7
with out it fighting you.然后,您可以运行
gem uninstall json -v 1.7.7
而不会与您发生冲突。 If you want to undo all this just run gem install json -v 1.7.7 --default
如果您想撤消这一切,只需运行
gem install json -v 1.7.7 --default
I have been experiencing a problem with default versions of gems, and the accepted answer did not work for me.我一直在使用默认版本的 gems 时遇到问题,并且接受的答案对我不起作用。 What worked for me was to install the same version as the default, but without the default flag, and then uninstall it.
对我有用的是安装与默认版本相同的版本,但没有默认标志,然后将其卸载。
gem install json -v '1.7.7'
Then once that is finished:然后一旦完成:
gem uninstall json -v '1.7.7'
may be this will help you....可能这会帮助你....
bundle exec gem uninstall GEM_NAME
if above cmd not work then try this如果上面的 cmd 不起作用,那么试试这个
execute this either in irb or in a script proper:在 irb 或适当的脚本中执行此操作:
`gem list --no-versions`.split("\n").each do |gem|
`gem list -d #{gem}`.gsub(/Installed at(.*):.*/).each do |dir|
dir = dir.gsub(/Installed at(.*): /,'').gsub("\n", '')
system "gem uninstall #{gem} -aIx -i #{dir}"
end
end
if above both are fails then try this如果以上两个都失败了,那么试试这个
go to your rvm dir.. where all gems are install then manually remove that gem which you want.. such as in my case my gem dir location is /home/user_name/.rvm/gems/ruby-1.9.3-p194/gems转到您的 rvm 目录 .. 安装所有 gem,然后手动删除您想要的 gem .. 例如在我的情况下,我的 gem 目录位置是 /home/user_name/.rvm/gems/ruby-1.9.3-p194/宝石
open your terminal and then打开你的终端然后
Step 1步骤1
open interactive ruby打开交互式红宝石
irb
Step 2第2步
inside that use the command在里面使用命令
Gem.default_specifications_dir
it will provide you an address like:它会为您提供一个地址,例如:
"/home/user/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/specifications/default"
Step 3第 3 步
then break out of irb and move to that address directory by然后突破 irb 并通过以下方式移动到该地址目录
cd /home/user/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/specifications/default
Step 4第4步
just delete that gem's gemspec file by:只需通过以下方式删除该 gem 的 gemspec 文件:
rm gemname-2.1.4.gemspec
Hope this works!希望这有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.