ios 卸载后无法安装可可豆荚,导致报错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30812777/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 06:24:14  来源:igfitidea点击:

Cannot install cocoa pods after uninstalling, results in error

iosterminalinstallationcocoapods

提问by Adrian Wacker

I removed cocoa pods because it claimed it had installed, but kept saying the command pod wasn't found afterward. When trying to reinstall cocoapods (sudo gem install cocoa pods -v) I get this error:

我删除了可可豆荚,因为它声称已安装,但后来一直说没有找到命令豆荚。尝试重新安装 cocoapods ( sudo gem install cocoa pods -v) 时出现此错误:

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/pod

错误:执行 gem 时 ... (Errno::EPERM) 不允许操作 - /usr/bin/pod

Screenshot for error

错误截图

Any ideas?

有任何想法吗?

回答by Kyle Browning

As it has been pointed out below by Ramesh Ramchandaran, this is a cleaner way of doing it, instead of getting around the Security features of OS X.

正如Ramesh Ramchandaran下面指出的那样,这是一种更简洁的方法,而不是绕过 OS X 的安全功能。

sudo gem install -n /usr/local/bin cocoapods


Original Answer

原答案

I'm assuming you're running OS X 10.11.

我假设您运行的是 OS X 10.11。

This is happening because Apple has enabled rootless on the new install.

发生这种情况是因为 Apple 在新安装中启用了 rootless。

If you type:

如果您键入:

sudo nvram boot-args="rootless=0"; sudo reboot

in terminal.app, your computer will reboot with it disabled.

在 中terminal.app,您的计算机将在禁用的情况下重新启动。

Once that is done, type:

完成后,键入:

sudo gem install cocoapods -V

the -Vis for verbose and will spit out any errors if they happen.

-V是详细的,如果发生错误,会吐出任何错误。

回答by Rajesh Ramachandran

As rootless does not affect /usr/local/bin, the following succeeds:

由于 rootless 不影响 /usr/local/bin,以下成功:

sudo gem install -n /usr/local/bin cocoapods

Any caveats?

有什么注意事项吗?

回答by Drew

Using home-brewor custom $GEM_HOMEcan help resolving the issue. I did clean installation of ruby with brew: brew install ruby Now the gemstuff seem to happen relative to my /usr/local/bin*, which is exactly what I needed.

使用home-brew或自定义$GEM_HOME可以帮助解决问题。我用brew干净地安装了 ruby : brew install ruby 现在这些gem东西似乎相对于我的/usr/local/bin*,这正是我所需要的。

回答by PatrickDotStar

I recommend installing all your gems into your .gemfolder in your home folder to avoid using sudoor a ruby version manager as other people suggest.

我建议将所有 gem 安装到.gem主文件夹中的文件夹中,以避免sudo像其他人建议的那样使用ruby 版本管理器。

All you have to do is update your .bash_profileby adding these 2 lines. (Don‘t forget to restart your terminal after applying these changes)

您所要做的就是.bash_profile通过添加这两行来更新您的。(不要忘记在应用这些更改后重新启动终端)

export GEM_HOME=~/.gem
export PATH="$GEM_HOME/bin:$PATH"

回答by Naishta

After updgrading from Yosemite to El Capitan ( 10.11.4), I kept getting the below error message while trying to 'reinstall' Cocoapods ( after trying out pretty much all the solutions under different Stackoverflow threads and the Cocoapods issue-page itself, for the same issue)

从优胜美地升级到 El Capitan(10.11.4)后,我在尝试“重新安装”Cocoapods 时不断收到以下错误消息(在尝试了不同 Stackoverflow 线程和 Cocoapods 问题页面本身下的几乎所有解决方案之后,对于同样的问题)

"Could not find a valid gem 'cocoapods' (>= 0) in any repository"

However, quit terminal, restarted system, created new Xcode project from the scratch and then when i did 'pod install', it worked.

但是,退出终端,重新启动系统,从头开始创建新的 Xcode 项目,然后当我这样做时'pod install',它起作用了。

Note: I was trying to use Alamofire and SwiftyJson cocoapods

注意:我试图使用 Alamofire 和 SwiftyJson cocoapods