Running pod setup gives me "bad interpreter: No such file or directory" error
Asked Answered
B

20

268

Recently I tried to do pod setup and I get this error:

-bash: /usr/local/bin/pod: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory

I followed Ray Wenderlich's guide to install CocoaPods and I get this issue so I have no idea what is going on.

Byroad answered 15/7, 2015 at 22:20 Comment(5)
Ruby installation incorrect?Graeco
What is your system? [Darwin (Mac OS X)?] How did you install Ruby? [brew? ports? from source?] How are you managing Ruby versions? [RVM? rbenv?] Which guide by Ray Wenderlich did you follow? [there are several]Godiva
The error basically tells you that the interpreter you are attempting to use is not there. Look at the /usr/local/bin/pod, first line (one that starts with #!) and you should see the ruby interpreter there. Is there anything in /usr/local/opt/ruby? Are you using rbenv, rvm?Malpractice
@Mircea, do you know what that file is for?Archway
Mine shows version 2.3 in usr/local/binpod file but I believe I have Ruby 2.6. So getting similar error. Do you know a clean way to update this?Archway
B
17

i fixed it by running brew install ruby

Byroad answered 28/8, 2015 at 8:45 Comment(1)
I had to reinstall rew uninstall cocoapods rew install cocoapods after I installed ruby to make the error go away.Propagation
B
514

I encountered this problem when upgrading to Mac OS High Sierra.

This was my fix:

sudo gem install cocoapods

I found this answer on the CocoaPods issue list on Github.

Bono answered 22/9, 2017 at 16:22 Comment(10)
This one fixed it for me.Ethbun
don't forget sudo: sudo gem install cocoapodsPleuropneumonia
I had the same issue and doing a brew update and brew upgrade installed the latest cocoapods for me and did the trickAzral
Downvoted because of the use of sudo. See various answers on StackExchange for installing ruby/gems without it. e.g. #31414749Rhizoid
This also has fixed it for me, Plus one for the great answer, this should be the accepted answerKumasi
If this doesn't help, try restarting Terminal.Kentiga
This helps with Catalina too.Gramnegative
This fixed it for me on macOS Catalina. Thank you :)Flo
I didn't think it will help but it did, macOS Catalina.Behnken
Ugh! You should never use sudo to install gems. I wrote a detailed, top-rated answer for safely installing gems on a Mac: https://mcmap.net/q/65113/-you-don-39-t-have-write-permissions-for-the-library-ruby-gems-2-3-0-directory-mac-userMiffy
B
128

This happened when I upgraded to Catalina. I solved it by running:

sudo gem install -n /usr/local/bin ruby
sudo gem install -n /usr/local/bin cocoapods
Berberidaceous answered 15/10, 2019 at 12:1 Comment(3)
This was the solution for me after upgrading to Catalina.Merrimerriam
You might have to install separate package for the ruby development environment, ruby-dev or ruby-devel for example.Margay
Along with this I also had an issue with openssl that I had to fix first - brew uninstall openssl & brew install opensslKezer
E
77

After upgraded to High Sierra, I got the same error, just reinstalled the cocoapods

sudo gem install -n /usr/local/bin cocoapods
Eanes answered 18/10, 2017 at 17:5 Comment(3)
Worked well, nice!Holomorphic
This is needed for High Sierra. Thank you.Trademark
For those who updated to Catalina, this is needed as well.Quar
I
54

Same issue I was facing when I updated our system from Sierra to Mojave. Also works for Catalina

The following steps worked:

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

I got the help from the following link.

Impetuosity answered 29/5, 2019 at 11:27 Comment(3)
Getting the same issue after upgrading to Catalina. This helps! Use Sudo in front to get write permission fwiw.Avocation
I ended up here after Catalina installation. This works well.Melainemelamed
worked for me after updating 10.14 Mojave to 10.15 CatalinaEsme
O
23
brew link --overwrite cocoapods

This line saved my day.

Ollayos answered 29/8, 2018 at 7:48 Comment(2)
Eventually this fixed the issue for meGeer
Also saved my day!Frangible
B
17

i fixed it by running brew install ruby

Byroad answered 28/8, 2015 at 8:45 Comment(1)
I had to reinstall rew uninstall cocoapods rew install cocoapods after I installed ruby to make the error go away.Propagation
B
15

The following worked for me:

Select Command Line Tools in XCode.

    XCode > Preferences > Locations > Command Line Tools > XCode 11.X.X

In terminal execute:

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

https://stackoverflow.com/a/60464653

Babism answered 22/5, 2020 at 9:13 Comment(0)
J
7

After upgrading from OS X Mojave to OS X Catalina I received this message when running pod init or pod --version: -bash: /Users/mangolassi/.gem/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory

I don't like the idea of sudo gem install cocoapods so I have my .cocoapods folder in my user directory and I've modified my .bash_profile to point to it. The error I received was because the version 2.3 was hard coded in this file: /Users/eric/.gem/bin/pod and Catalina came with 2.6.

It's possible that using sudo install would overwrite this file successfully, and probably does, but I wanted to keep my original setup.

I was able to to just modify the first shebang line of the file /Users/eric/.gem/bin/pod to have a path with 2.6 instead of 2.3 and it worked. The entire change was changing the '3' to a '6' in my chase as the version was still '2'.

Jaquenette answered 4/11, 2019 at 21:51 Comment(1)
Nice! Only this answer worked for me. Apparently after upgrading to Catalina ruby 2.3 was replaced with 2.6Uterus
S
6

While I'm trying to install again then 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
Spirogyra answered 27/9, 2017 at 12:36 Comment(1)
Most likely you didn't need to uninstall. That error just says you don't have the correct permissions to do what you were trying to do. So adding sudo was all you needed. See the comment from [stackoverflow.com/users/877341/blackhawk4152] aboveManamanacle
W
6

On my mac this solved the problem:

brew uninstall cocoapods

brew install cocoapods
Wellappointed answered 22/11, 2017 at 11:44 Comment(0)
A
5

for MACOS X Catalina

Tried most of the answers but none worked. If the above doesn't work try Opening Xcode preferences > Locations > selecting Command Line Tools to Xcode. Then install cocoapods

sudo gem install -n /usr/local/bin cocoapods
Adlib answered 20/10, 2020 at 22:12 Comment(0)
M
5

The error in the original post is due to an improperly configured Ruby environment. You should never use sudo to install gems, no matter how many times you see it as an accepted answer on Stack Overflow.

At a high level, setting up a proper Ruby development environment on a Mac involves six steps:

  1. Install Homebrew (which also installs the prerequisite Apple command line tools)
  2. Install a Ruby manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew
  3. 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
  4. Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked
  5. Install a specific version of Ruby using the Ruby manager
  6. Switch to that version of Ruby using the Ruby manager

My personal preference is chruby with ruby-install. For a step-by-step guide, check out my detailed tutorial for setting up Ruby on a Mac.

Miffy answered 31/12, 2020 at 17:39 Comment(0)
D
4

I came across a similar issue when I tried upgrading the cocoa pods version using:

brew upgrade cocoapods

To fix this, cocopaods had to be linked with xcodeproj using the command below:

brew link cocoapods

If the linking fails, then you should be able to link by overwriting the previously existing link as follows:

brew link --overwrite cocoapods
Derrik answered 7/6, 2021 at 6:18 Comment(0)
R
2

Fixed with

brew upgrade cocoapods
Rhizoid answered 6/4, 2018 at 0:57 Comment(0)
K
1

The "rubyist approved" way of doing this is to install a ruby version manager (rbenv) and install cocoapods through that. Messing with sudo and your rubygems is going to lead to tears.

Karlotte answered 25/3, 2020 at 23:11 Comment(0)
C
0

In my case nothing of the above worked. I had ruby 2.3.0 installed and I had to downgrade to 2.0.0:

gem update --system 2.0.0

Chauvinism answered 6/7, 2019 at 15:9 Comment(0)
L
0

Find the pod file. Mine was located at usr/local/bin/pod

You'll find that the top line says version 2.3. Edit this file to the correct version number. Save a copy of the original incase you mess it up.

Try your pod related commands again.

Worked for me after days of trying everything.

Lapham answered 19/3, 2021 at 21:13 Comment(0)
Y
0

vi pod then replace the ruby path 2.3 one to the path which u get by using which ruby command in terminal then do pod setup it will work this worked for me after trying all the listed solutions .

Yonah answered 11/9, 2021 at 23:27 Comment(0)
M
0

re-installing ruby solving issues on my case (error happen after I upgrade Mac OS to Monterey). it's take a bit of time to reinstall but it worked

Mantelet answered 11/1, 2023 at 5:0 Comment(0)
N
0

Technically Symlink to Ruby is broken.

Fix it by executing command: ln -s /opt/homebrew/Cellar/ruby/<version> /opt/homebrew/opt/ruby

Nakasuji answered 27/8, 2023 at 9:9 Comment(2)
This is a duplicate answer. Many users have described methods similar to solve the problem.Achromat
Mostly others are suggesting to reinstall ruby or cocoapods. Both are installed correctly. Its only symlink issue. I do not find any such answer.Nakasuji

© 2022 - 2025 — McMap. All rights reserved.