CocoaPods not working in macOS High Sierra

RubyCocoapodsMacos High-Sierra

Ruby Problem Overview


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.

Ruby Solutions


Solution 1 - Ruby

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

sudo gem install cocoapods

[1]: https://github.com/CocoaPods/CocoaPods/issues/6778 "Github Issue Tracker"

Solution 2 - Ruby

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...!!!

Solution 3 - Ruby

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

Solution 4 - Ruby

This worked for me, although I had to do

sudo gem install cocoapods

Solution 5 - Ruby

This solved my problem:

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

Solution 6 - Ruby

Simply run below command:

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

Solution 7 - Ruby

This works for me:

brew link --overwrite cocoapods

Solution 8 - Ruby

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 :)

Solution 9 - Ruby

Try using

sudo gem update --system

Before

sudo gem install cocoapods

This worked for me

Solution 10 - Ruby

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

Solution 11 - Ruby

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

Solution 12 - Ruby

Go to Terminal...

step 1). sudo gem install cocoapods

after completion of install cocoa pods then

step 2). pod repo update

Completed

Solution 13 - Ruby

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.

Solution 14 - Ruby

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

Solution 15 - Ruby

##Sudo-less .zhs-friendly solution

Modern macOS discourages using sudo and shifts from bash to zsh, so this answer may be useful if you are not going to fight with the fashion.

  1. Insure that .zshenv exists by touch ~/.zshenv command. Configure the RubyGems environment by adding following lines:

    export GEM_HOME=$HOME/.gem
    export PATH=$GEM_HOME/bin:$PATH
    

Don't forget to relaunch Terminal. 2. Run gem install cocoapods.

Solution 16 - Ruby

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

Solution 17 - Ruby

Had a same issue, resolution:

  1. Reinstall ruby

    brew install ruby

  2. Reinstall Cocoa Pods

    sudo gem install cocoapods

Solution 18 - Ruby

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

Fix is simply installing Cocoapods (again):

sudo gem install cocoapods

Solution 19 - Ruby

Running this on terminal worked for me:

sudo gem install cocoapods

Solution 20 - Ruby

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

Solution 21 - Ruby

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.

Solution 22 - Ruby

I had the same issue after upgrading to Catalina.

  1. I updated ruby install by first installing brew and ruby using these directions. https://gorails.com/setup/osx/10.15-catalina (but only ruby, not rails, etc.)

  2. Then I reinstalled cocoapods using the instructions above.

sudo gem install cocoapods

Then after all that I still received the error above. Then I typed 'zsh' to spawn a new shell and pull in configuration settings in the ~/.zshrc file. After this 'pod update' command worked again.

Solution 23 - Ruby

    curl -sSL https://get.rvm.io | bash -s stable
    sudo update gems
    rvm install 2.6.0
    sudo gem install cocoapods

Solution 24 - Ruby

I used homebrew to install cocoapods on High Sierra (macOS 10.13.6) it works for me

brew install cocoapods

after this flutter doctor shows no errors.

I am able to deploy my Flutter app to IOS XS Max

Solution 25 - Ruby

If cannot install new version cocoapods, example below:
1. Please remove Command line tools
sudo rm -rf /Library/Developer/CommandLineTools
2. Install new Command line tools version
sudo xcode-select --install
3. after installing run below command
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaciej SwicView Question on Stackoverflow
Solution 1 - RubyzeisiView Answer on Stackoverflow
Solution 2 - Rubymital solankiView Answer on Stackoverflow
Solution 3 - RubyDanh HuynhView Answer on Stackoverflow
Solution 4 - RubyAndrew SmithView Answer on Stackoverflow
Solution 5 - RubyĐorđe NilovićView Answer on Stackoverflow
Solution 6 - RubyHarshal WaniView Answer on Stackoverflow
Solution 7 - RubyYun CHENView Answer on Stackoverflow
Solution 8 - RubyT. HyldgaardView Answer on Stackoverflow
Solution 9 - RubyDavidView Answer on Stackoverflow
Solution 10 - RubySheshu SoloView Answer on Stackoverflow
Solution 11 - RubydjunodView Answer on Stackoverflow
Solution 12 - RubyAzaharuddin MohammadView Answer on Stackoverflow
Solution 13 - RubyJiang WangView Answer on Stackoverflow
Solution 14 - Rubyuser8851874View Answer on Stackoverflow
Solution 15 - RubykelinView Answer on Stackoverflow
Solution 16 - RubyHimanthView Answer on Stackoverflow
Solution 17 - RubyAnton EreginView Answer on Stackoverflow
Solution 18 - RubyShobhit CView Answer on Stackoverflow
Solution 19 - RubyANUJ TAYALView Answer on Stackoverflow
Solution 20 - RubySonam ManiarView Answer on Stackoverflow
Solution 21 - Rubyuser1575878View Answer on Stackoverflow
Solution 22 - RubyLarry RickerView Answer on Stackoverflow
Solution 23 - RubyKevin LanoView Answer on Stackoverflow
Solution 24 - RubyAlbert HuiView Answer on Stackoverflow
Solution 25 - RubysiddhantView Answer on Stackoverflow