简体   繁体   English

如何修复损坏的系统 Ruby 安装

[英]How to fix a broken System Ruby installation

My Mac system Ruby installation is completely broken.我的Mac系统Ruby安装彻底坏了。

I've seen several posts recommending me to set up RVM or rbenv but I'm trying to install an Xcode pod (cocoapods), and I have no idea why my system Ruby is so broken.我看过几篇推荐我设置 RVM 或 rbenv 的帖子,但我正在尝试安装 Xcode 吊舱(cocoapods),我不知道为什么我的系统 Ruby 如此损坏。

When I run gem , I get the following output:当我运行gem时,我得到以下 output:

NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/coffee-script-source-1.11.1.gemspec:16.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/em-websocket-0.5.1.gemspec:15.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/escape-0.0.4.gemspec:18.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/fuzzy_match-2.0.4.gemspec:17.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/i18n-0.9.5.gemspec:17.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0/specifications/nokogiri-1.5.6.gemspec:22.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/rouge-2.2.1.gemspec:18.
NOTE: Gem::Specification#rubyforge_project= is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::Specification#rubyforge_project= called from /Library/Ruby/Gems/2.3.0/specifications/sass-3.7.4.gemspec:21.
RubyGems is a sophisticated package manager for Ruby.  This is a
basic help message containing pointers to more information.

and it seems that these are just deprecation warnings, and, from some other posts, that the answer is to simply run gem pristine --all --no-extensions .似乎这些只是弃用警告,并且从其他一些帖子中,答案是简单地运行gem pristine --all --no-extensions

When I run essentially any gem command, I get a permissions error:当我基本上运行任何gem命令时,我得到一个权限错误:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0 directory.

How do I reset my system Ruby?如何重置我的系统 Ruby? I don't use Ruby and I had run the command gem install cocoapods yesterday.我不使用 Ruby 并且我昨天运行了命令gem install cocoapods Since then it's been unusable.从那以后它就无法使用了。

Note that basically you should install Ruby by yourself with tools like rbenv , but if you don't want to do it, please refer to the answer below.请注意,基本上您应该使用 rbenv 之类的工具自己安装rbenv ,但是如果您不想这样做,请参考下面的答案。


System Ruby is installed for root , so you need sudo command to interact with it.系统 Ruby 安装为root ,因此您需要sudo命令与之交互。 Try sudo gem install cocoapods .尝试sudo gem install cocoapods

(Btw, gem command with no sub commands just shows the usage, which is not broken ) (顺便说一句,没有子命令的gem命令只显示用法,没有损坏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM