CocoaPods not working in macOS High Sierra
Asked Answered
U

25

164

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.

Unwished answered 6/6, 2017 at 17:26 Comment(3)
Did you update the Command Line Tools?Viscount
@Viscount Yes, sudo xcode-select -s /Applications/Xcode-beta.app and sudo xcode-select --install and followed the GUI from there.Unwished
I was thinking of the ones here: developer.apple.com/download/more I often find external tools don't work until I install those.Viscount
P
418

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

sudo gem install cocoapods
Prefect answered 6/6, 2017 at 18:38 Comment(8)
A simple "brew reinstall cocoapods" worked (as it runs this exact command for you). Thank you for pointing that out.Maag
Although this works, it should definitely be a CocoaPods issue, since it is unable to locate the updated Ruby version. Probably reinstalling it just checks for the installation again and therefore "fixes" it.Villon
gem install cocoapods - throws no implicit conversion of nil to string error but "brew reinstall cocoapods" did the job. thanks @MaagHazzard
gem install -n /usr/local/bin cocoapods helps meLepanto
Since i updated to 10.13 OS, Provided sudo gem install cocoapods again & it's worked.Skyway
I hit this on Mojave on omitted sudo, so just gem install cocoapods and it worked, thanksDrawstring
Works for macOS Catalina (v10.15), as well.Batten
Works for macOS Catalina too.Lanlana
C
120

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

Chattel answered 5/10, 2017 at 2:16 Comment(5)
I got "ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem" when running the first command, but running the second still made "pod install" work. Thanks.Carliecarlile
Despite the "warning", I'm going to say thanks here anyway. This was the only thing that worked for me. Simply reinstalling cocoapods (several times) made no difference until I did both of these steps. So - thanks!Reavis
I had to run the ruby update through the following command: sudo gem update -n /usr/local/bin --systemMacao
Worked for me (cocoapods 1.5.3).Twibill
After literally trying hundreds of other proposed solutions and spending hours and hours this one finally worked. I can now safely say I love you just as much as I hate the Apple/Mac dev environment! Thanks.Amir
S
30

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
Skateboard answered 2/10, 2017 at 6:5 Comment(1)
This is the only solution that seemed to work for me. ThanksCheboksary
B
12

This worked for me, although I had to do

sudo gem install cocoapods
Blanca answered 20/9, 2017 at 19:51 Comment(0)
R
11

This solved my problem:

$ brew install ruby
$ gem install -n /usr/local/bin cocoapods
Rizzo answered 23/10, 2017 at 12:28 Comment(3)
Please give a short explanation of what the posted code does so people that are new to this technology have a change to understand and re-use your answer :-)Costanzo
People new to cocoapods should know how to read like the others.Washwoman
@MathieuVIALES, the "brew install ruby" assumes you already have Homebrew packager (brew.sh). That command then installs (or probably technically re-installs ruby since you actually need ruby to install Homebrew itself). The next line "gem install -n /usr/local/bin cocoapods" reinstalls the CocoaPod program (more at cocoapods.org).Kila
H
9

Simply run below command:

sudo gem install -n /usr/local/bin cocoapods
Hamman answered 30/12, 2017 at 16:55 Comment(0)
C
8

This works for me:

brew link --overwrite cocoapods
Corking answered 5/10, 2017 at 13:35 Comment(0)
C
6

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

Corrinacorrine answered 27/9, 2017 at 8:43 Comment(0)
S
6

Try using

sudo gem update --system

Before

sudo gem install cocoapods

This worked for me

Sexism answered 29/9, 2017 at 8:37 Comment(0)
P
6

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

Philhellene answered 23/5, 2018 at 6:7 Comment(0)
B
5

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
Bulgaria answered 16/10, 2017 at 22:37 Comment(1)
Finally ! Deleting old pod executable before installing cocoapods worked for meLon
H
4

Go to Terminal...

step 1). sudo gem install cocoapods

after completion of install cocoa pods then

step 2). pod repo update

Completed

Hiatus answered 16/11, 2017 at 6:23 Comment(0)
C
4

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.

Carnivorous answered 20/4, 2018 at 6:48 Comment(0)
O
3

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
Outtalk answered 6/11, 2017 at 18:33 Comment(3)
This is just a repeat of this existing answer, isn't it?Gallman
this fixed it for meInvasion
Not working for meChaffer
M
2

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.
Maillol answered 10/2, 2020 at 20:14 Comment(1)
ERROR: While executing gem ... (Errno::EACCES) Permission denied @ dir_s_mkdir - /Users/shubhamojha/.local/share/gem/specsChaffer
G
1

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
Gena answered 27/9, 2017 at 12:34 Comment(0)
T
1

Had a same issue, resolution:

  1. Reinstall ruby

    brew install ruby

  2. Reinstall Cocoa Pods

    sudo gem install cocoapods

Trinidadtrinitarian answered 27/11, 2017 at 22:27 Comment(0)
C
1

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

Fix is simply installing Cocoapods (again):

sudo gem install cocoapods
Charteris answered 3/12, 2017 at 12:53 Comment(0)
R
1

Running this on terminal worked for me:

sudo gem install cocoapods
Rheostat answered 14/6, 2018 at 12:40 Comment(0)
T
0

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
Toth answered 23/10, 2019 at 11:59 Comment(0)
D
0

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.

Denazify answered 17/11, 2019 at 9:0 Comment(0)
S
0

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.

Sabadell answered 1/1, 2020 at 12:50 Comment(0)
G
0
    curl -sSL https://get.rvm.io | bash -s stable
    sudo update gems
    rvm install 2.6.0
    sudo gem install cocoapods
Groveman answered 2/12, 2020 at 13:57 Comment(1)
Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotesTwiddle
V
0

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

Verbid answered 6/12, 2021 at 2:26 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewMasterly
A
-1
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
Adal answered 10/3, 2020 at 4:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.