最近我尝试做豆荚设置,我得到这个错误:
-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环境造成的。你永远不应该使用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。这方面的说明在我的答案上面链接。
其他回答
找到pod文件。我的位于usr/local/bin/pod
您会发现顶部一行显示的是版本2.3。将此文件编辑为正确的版本号。保存一份原件以防你搞砸了。
再次尝试与荚相关的命令。
我试了好几天,还是成功了。
我通过运行brew install ruby来修复它
vi豆荚 然后将ruby路径2.3 1替换为你使用的路径 终端中的哪个ruby命令 然后做吊舱设置,它将工作 在尝试了所有列出的解决方案后,这对我来说很有效。
MACOS X Catalina
我试了大部分答案,但没有一个管用。如果上面没有工作尝试打开Xcode首选>位置>选择命令行工具到Xcode。然后安装cocoapods
sudo gem install -n /usr/local/bin cocoapods
从OS X Mojave升级到OS X Catalina后,我在运行pod init或pod——version时收到了这条消息: bash: /用户/ mangolassi /。gem/bin/pod: /System/Library/Frameworks/ ruby .framework/Versions/2.3/usr/bin/ruby: bad interpreter:没有这样的文件或目录
我不喜欢sudo宝石安装cocoapods的想法,所以我有我的.cocoapods文件夹在我的用户目录,我已经修改了我的.bash_profile指向它。我收到的错误是因为2.3版本是硬编码在这个文件中: /用户/ eric /。gem/bin/pod和Catalina附带2.6。
使用sudo install可能会成功地覆盖这个文件,而且很可能是这样,但我想保留原来的设置。
我可以修改文件/Users/eric/的第一行shebang。Gem /bin/pod有一个2.6的路径,而不是2.3,它工作了。在我的追逐中,整个变化是将“3”改为“6”,因为版本仍然是“2”。