最近我尝试做豆荚设置,我得到这个错误:
-bash: /usr/local/bin/pod: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
我按照Ray Wenderlich的指南安装CocoaPods,我遇到了这个问题,所以我不知道发生了什么。
最近我尝试做豆荚设置,我得到这个错误:
-bash: /usr/local/bin/pod: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
我按照Ray Wenderlich的指南安装CocoaPods,我遇到了这个问题,所以我不知道发生了什么。
当前回答
“ruby主义者认可的”方法是安装一个ruby版本管理器(rbenv),并通过它安装cocoapods。乱搞sudo和你的红宝石会让你流泪的。
其他回答
在我的案例中,上述任何一种方法都不起作用。我安装了ruby 2.3.0,我不得不降级到2.0.0:
Gem更新——系统2.0.0
我通过运行brew install ruby来修复它
“ruby主义者认可的”方法是安装一个ruby版本管理器(rbenv),并通过它安装cocoapods。乱搞sudo和你的红宝石会让你流泪的。
当我尝试升级可可荚版本时,我遇到了类似的问题:
brew upgrade cocoapods
为了解决这个问题,cocopaods必须使用下面的命令链接到xcodeproj:
brew link cocoapods
如果链接失败,那么你应该能够通过覆盖之前存在的链接进行链接,如下所示:
brew link --overwrite cocoapods
原始文章中的错误是由于配置不正确的Ruby环境造成的。你永远不应该使用sudo来安装gems,无论你在Stack Overflow上看到多少次它是一个可接受的答案。
基本上,在Mac上建立一个合适的Ruby开发环境包括六个步骤:
Install Homebrew (which also installs the prerequisite Apple command line tools) Install a Ruby manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew Configure the Ruby manager by adding the appropriate lines to your shell file (~/.bash_profile or ~/.zshrc) - each manager will have instructions for doing this, and this is a typical step that people miss Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked Install a specific version of Ruby using the Ruby manager Switch to that version of Ruby using the Ruby manager
我个人的偏好是chruby和ruby-install。更多细节和脚本,可以自动化这整个过程,看看我的答案在这里: https://stackoverflow.com/a/54873916/928191
正如已接受的答案所提到的,您也可以用Homebrew安装Ruby,但还需要确保在shell文件中设置了PATH。这方面的说明在我的答案上面链接。