CocoaPods not working in macOS High Sierra

你离开我真会死。 提交于 2019-12-20 08:05:45

问题


After upgrading to macOS High Sierra CocoaPods is not working. While it is tempting to move away from CocoaPods, it's unfortunately not in scope right now. The error message is below.

zsh: /Users/****/.gems/bin/pod: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin: no such file or directory

I realize that the error stems from Ruby being upgraded but what is the easies fix? Trying to make CocoaPods use the new ruby version yields other errors.

Edit: For now i installed Ruby 2.0 with rvm install 2.0.0 and rvm use 2.0.0 and then reinstalled CocoaPods sudo gem install cocoapods. Seems to be working now.


回答1:


According to https://github.com/CocoaPods/CocoaPods/issues/6778 reinstalling CocoaPods should solve this issue:

sudo gem install cocoapods



回答2:


After upgrading to macOS High Sierra, get it fixed with following commands:

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

once it will be finished then write below command:

pod install

This solution has worked for me...!!!




回答3:


I got this error while installing the CocoaPods

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.

And I used this statement. It worked!

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



回答4:


This worked for me, although I had to do

sudo gem install cocoapods



回答5:


This solved my problem:

$ brew install ruby
$ gem install -n /usr/local/bin cocoapods



回答6:


Simply run below command:

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



回答7:


So I ran into this problem as well after having updated to High Sierra, and it seems like there's been some changes to a location of file that the ruby framework was accessing.

You can solve it using the,

sudo gem install cocoapods

and then update pods as well with for safe measures

pod repo update 

and finally

pod install

to make the pod file work again.

Hope this helps out :)




回答8:


This works for me:

brew link --overwrite cocoapods



回答9:


Try using

sudo gem update --system

Before

sudo gem install cocoapods

This worked for me




回答10:


Go to Terminal...

step 1). sudo gem install cocoapods

after completion of install cocoa pods then

step 2). pod repo update

Completed




回答11:


For me, I had to:

gem uninstall cocoapods
which pod

It still showed it in the path, so I deleted that. Made sure it still didn't show up.

Then

gem install cocoapods



回答12:


I also encountered this error after installing High Sierra.

ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.

I used the following statement identified by Danh Huynh (see above) and It worked!

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



回答13:


Cocoapods install process:

  1. sudo gem install cocoapods (if you have any problem cocoapds, please update gem file)

  2. sudo gem update --system

  3. sudo gem install cocoapods




回答14:


MacOS High Sierra uses ruby 2.3 by default. After upgrading to it, some old ruby gems might not function properly. This problem occurs to me when I ran the bundle command (bundler is a ruby gem; it has a utility called bundle).

So, to clarify, any old ruby gems (cocoapods, bundler, etc) that are trying to access ruby 2.0 will fail.

The solution is to reinstall those old gems in a directory where you have permissions to write.

For cocoapods,

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

will do the trick.

You can optionally upgrade your gem system if you like before the install:

sudo gem update --system

This may prompt to you that the upgrading has failed. But actually, if you type:

gem --version

You can see that the upgrading has been successful.

For bundler or other gems, try to do the same:

sudo gem install gem-to-install(for example, bundler) -n /usr/local/bin

About the -n option. Don't miss that. You can check the gem documentation if you want.

So, the solution is all about reinstalling the old gem to a proper directory.




回答15:


Had a same issue, resolution:

  1. Reinstall ruby

    brew install ruby

  2. Reinstall Cocoa Pods

    sudo gem install cocoapods




回答16:


This is a common problem when upgraded to Mac OSX High Sierra.

Fix is simply installing Cocoapods (again):

sudo gem install cocoapods



回答17:


Running this on terminal worked for me:

sudo gem install cocoapods



回答18:


While I'm doing the same I got another error saying that

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

Then I did this and worked fine.

sudo gem uninstall cocoapods

sudo gem install cocoapods



回答19:


After using the below command on the terminal, I am able to install cocoa pods in my project.

sudo gem install cocoapods --source http://rubygems.org



回答20:


I faced this issue also but fixed it in less dramatical way as various re-installation / updating. Just updated PATH environment variable to point out my existing (2.6.0) ruby version.



来源:https://stackoverflow.com/questions/44396215/cocoapods-not-working-in-macos-high-sierra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!