Cocoapods: Brew based CocoaPods CLI fails in MacOS 10.15 Catalina due incorrect fallback to Ruby 2.3

Created on 1 Jul 2019  ·  55Comments  ·  Source: CocoaPods/CocoaPods

Report

TL;DR Work-around

Install from gem instead of brew, via gem install cocoapods per related https://github.com/CocoaPods/CocoaPods/issues/6778

What did you do?

Tried to run cocoapods on Mac 10.15, from a Brew based installation

type pod

What did you expect to happen?

Brew based cocoapods installer should link to available "Current" Ruby version, instead of falling back to 2.3, which hasn't been available for a while.

What happened instead?

Brew defaulted to using unavailable Ruby 2.3, as in the case of the related High Sierra bug:

Fails with following one-line error message
/usr/local/Cellar/cocoapods/1.7.3/bin/pod: /usr/local/Cellar/cocoapods/1.7.3/libexec/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/Cellar/cocoapods/1.7.3/bin/pod: line 2: /usr/local/Cellar/cocoapods/1.7.3/libexec/bin/pod: Undefined error: 0

CocoaPods Environment

Mac 10.15 / Catalina
Brew based cocoapods - defaults to 2.3, instead of "Current"

This won't run due to reliance on deprecated Ruby 2.3 which does not exist on later Mac versions.

Project that demonstrates the issue

Base Mac 10.15 install, install / upgrade cocoapods, then try to run

help wanted awaiting input workaround available

Most helpful comment

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

All 55 comments

Still doesn't work on the official release of Catelina. Tried the "sudo gem install -n /usr/local/bin cocoapods " and "brew install cocoapods --build-from-source", still not working.

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Can confirm that this solution works.

brew upgrade cocoapods solved it for me 🎉

@CathyXian solution worked great. Thanks a lot.

-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby:

solve this issue:

sudo gem install cocoapods

@iHTCboy Thanks its worked for me.

@iHTCboy +1

brew upgrade cocoapods solved it for me 🎉

Had to
brew link --overwrite cocoapods
afterwards otherwise it still won't work

check your Xcode path, you can experience some issues if it cannot be found.

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

this work for me too! tks a lot!

@anderslemke didn't work for me but @CathyXian 's did!! Thanks a lot :D

I had to also re-install cocoapods:

gem uninstall cocoapods
gem install cocoapods

@anderslemke Upgrading cocoapods worked for me. Thanks.

Please use following command in Catalina. It works for me.

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

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Failed for me with:
An exception occurred within a child process:
Errno::ENOENT: No such file or directory - /usr/local/Cellar/cocoapods/1.8.4/libexec/bin/xcodeproj

Please use following command in Catalina. It works for me.

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

Confirm this works for me.

This worked for me
sudo gem install cocoapods

solve this issue:

sudo gem install cocoapods

this did it for me

brew upgrade cocoapods solved it for me 🎉

This work for me. Thanks!

"brew upgrade cocoapods" solved it for me

So can we close this? I cant seem confirmation or updates in Homebrew that dealt with the Ruby version and I am still not on Catalina to verify.

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Eres una riata, me programó la app completa, te amo

This issue came up for me with Catalina 15.2. "brew install cocoapods --build-from-source" with "brew link --overwrite cocoapods" did not work for me. I updated to Catalina 15.3 and did "brew reinstall cocoapods" which worked.

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

worked for me!

@CathyXian didn't work for me :(

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Batuhan-Yahsi:ios batuhan.yahsi$ brew install cocoapods --build-from-source
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> Updated Formulae
ejabberd         [email protected]       libheif          nrpe             openimageio      raylib           ssh-copy-id      whois
ffmpeg           gjs              libpq            octomap          poco             ruby-build       subversion       x265

Warning: cocoapods 1.8.4 is already installed and up-to-date
To reinstall 1.8.4, run `brew reinstall cocoapods`
Batuhan-Yahsi:ios batuhan.yahsi$ brew link --overwrite cocoapods
Warning: Already linked: /usr/local/Cellar/cocoapods/1.8.4
To relink:
  brew unlink cocoapods && brew link cocoapods
Batuhan-Yahsi:ios batuhan.yahsi$ brew upgrade cocoapods
Warning: cocoapods 1.8.4 already installed
Batuhan-Yahsi:ios batuhan.yahsi$ pod install
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
Downloading dependencies
Installing DoubleConversion (1.1.6)
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/cache.rb:114: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/request.rb:61: warning: The called method `slug' is defined here
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/cache.rb:100: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/request.rb:61: warning: The called method `slug' is defined here
Installing FBLazyVector (0.61.5)
Installing FBReactNativeSpec (0.61.5)
Installing Folly (2018.10.22.00)
Installing RCTRequired (0.61.5)
Installing RCTTypeSafety (0.61.5)
Installing React (0.61.5)
Installing React-Core (0.61.5)
Installing React-CoreModules (0.61.5)
Installing React-RCTActionSheet (0.61.5)
Installing React-RCTAnimation (0.61.5)
Installing React-RCTBlob (0.61.5)
Installing React-RCTImage (0.61.5)
Installing React-RCTLinking (0.61.5)
Installing React-RCTNetwork (0.61.5)
Installing React-RCTSettings (0.61.5)
Installing React-RCTText (0.61.5)
Installing React-RCTVibration (0.61.5)
Installing React-cxxreact (0.61.5)
Installing React-jsi (0.61.5)
Installing React-jsiexecutor (0.61.5)
Installing React-jsinspector (0.61.5)
Installing ReactCommon (0.61.5)
Installing Yoga (1.14.0)
Installing boost-for-react-native (1.63.0)
Installing glog (0.3.5)
[!] /bin/bash -c 
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="armv7"
    fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

./configure --host arm-apple-darwin

# Fix build for tvOS
cat << EOF >> src/config.h

/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif

/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif

/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

/bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

Here is mine

Batuhan-Yahsi:ios batuhan.yahsi$ brew install cocoapods --build-from-source
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/cask-versions, homebrew/core and homebrew/cask).
==> Updated Formulae
ejabberd         [email protected]       libheif          nrpe             openimageio      raylib           ssh-copy-id      whois
ffmpeg           gjs              libpq            octomap          poco             ruby-build       subversion       x265

Warning: cocoapods 1.8.4 is already installed and up-to-date
To reinstall 1.8.4, run `brew reinstall cocoapods`
Batuhan-Yahsi:ios batuhan.yahsi$ brew link --overwrite cocoapods
Warning: Already linked: /usr/local/Cellar/cocoapods/1.8.4
To relink:
  brew unlink cocoapods && brew link cocoapods
Batuhan-Yahsi:ios batuhan.yahsi$ brew upgrade cocoapods
Warning: cocoapods 1.8.4 already installed
Batuhan-Yahsi:ios batuhan.yahsi$ pod install
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `Folly` from `../node_modules/react-native/third-party-podspecs/Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.8.4/lib/cocoapods-core/cdn_source.rb:326: warning: URI.escape is obsolete
Downloading dependencies
Installing DoubleConversion (1.1.6)
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/cache.rb:114: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/request.rb:61: warning: The called method `slug' is defined here
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/cache.rb:100: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/usr/local/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods/downloader/request.rb:61: warning: The called method `slug' is defined here
Installing FBLazyVector (0.61.5)
Installing FBReactNativeSpec (0.61.5)
Installing Folly (2018.10.22.00)
Installing RCTRequired (0.61.5)
Installing RCTTypeSafety (0.61.5)
Installing React (0.61.5)
Installing React-Core (0.61.5)
Installing React-CoreModules (0.61.5)
Installing React-RCTActionSheet (0.61.5)
Installing React-RCTAnimation (0.61.5)
Installing React-RCTBlob (0.61.5)
Installing React-RCTImage (0.61.5)
Installing React-RCTLinking (0.61.5)
Installing React-RCTNetwork (0.61.5)
Installing React-RCTSettings (0.61.5)
Installing React-RCTText (0.61.5)
Installing React-RCTVibration (0.61.5)
Installing React-cxxreact (0.61.5)
Installing React-jsi (0.61.5)
Installing React-jsiexecutor (0.61.5)
Installing React-jsinspector (0.61.5)
Installing ReactCommon (0.61.5)
Installing Yoga (1.14.0)
Installing boost-for-react-native (1.63.0)
Installing glog (0.3.5)
[!] /bin/bash -c 
set -e
#!/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e

PLATFORM_NAME="${PLATFORM_NAME:-iphoneos}"
CURRENT_ARCH="${CURRENT_ARCH}"

if [ -z "$CURRENT_ARCH" ] || [ "$CURRENT_ARCH" == "undefined_arch" ]; then
    # Xcode 10 beta sets CURRENT_ARCH to "undefined_arch", this leads to incorrect linker arg.
    # it's better to rely on platform name as fallback because architecture differs between simulator and device

    if [[ "$PLATFORM_NAME" == *"simulator"* ]]; then
        CURRENT_ARCH="x86_64"
    else
        CURRENT_ARCH="armv7"
    fi
fi

export CC="$(xcrun -find -sdk $PLATFORM_NAME cc) -arch $CURRENT_ARCH -isysroot $(xcrun -sdk $PLATFORM_NAME --show-sdk-path)"
export CXX="$CC"

# Remove automake symlink if it exists
if [ -h "test-driver" ]; then
    rm test-driver
fi

./configure --host arm-apple-darwin

# Fix build for tvOS
cat << EOF >> src/config.h

/* Add in so we have Apple Target Conditionals */
#ifdef __APPLE__
#include <TargetConditionals.h>
#include <Availability.h>
#endif

/* Special configuration for AppleTVOS */
#if TARGET_OS_TV
#undef HAVE_SYSCALL_H
#undef HAVE_SYS_SYSCALL_H
#undef OS_MACOSX
#endif

/* Special configuration for ucontext */
#undef HAVE_UCONTEXT_H
#undef PC_FROM_UCONTEXT
#if defined(__x86_64__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__rip
#elif defined(__i386__)
#define PC_FROM_UCONTEXT uc_mcontext->__ss.__eip
#endif
EOF

# Prepare exported header include
EXPORTED_INCLUDE_DIR="exported/glog"
mkdir -p exported/glog
cp -f src/glog/log_severity.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/raw_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/stl_logging.h "$EXPORTED_INCLUDE_DIR/"
cp -f src/glog/vlog_is_on.h "$EXPORTED_INCLUDE_DIR/"

/bin/bash: ./configure: /bin/sh^M: bad interpreter: No such file or directory

Here is mine

did you try?
brew reinstall cocoapods

I solved this issue using the following command

brew install cocoapods

brew link --overwrite cocoapods

I solved it like this
cd ~/.cocoapods
rm -r repos
sudo gem install cocoapods
pod install

I'd recommend staying with brew over going the gem route.
This fixed it for me:

brew update
brew upgrade cocoapods ruby

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Thank you so much!

@ntgnst i had the same error, the solution for me was to configure git on OSX:

git config --global --add core.autocrlf input

see https://github.com/facebook/react-native/issues/28217#issuecomment-595901470

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

Thanks, this have worked for me.

brew upgrade cocoapods solved it for me 🎉

This solve my issue as well. Many thanks

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods
This solutions works for me.

Note: If you don`t have brew, install it by using following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

I had to run

brew reinstall cocoapods
brew link --overwrite cocoapods

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

you need run this code first: rm '/usr/local/bin/xcodeproj'

You need first Xcode 11 then you can run command

sudo gem install cocoapods

or

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

Otherwise it will fail.

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

This didn't work for me, but gem install cocoapods did (after chowning a bunch of stuff)

brew reinstall cocoapods

Worked for me.

sudo gem install cocoapods

This method works for me!
Thanks for sharing。

brew reinstall cocoapods
brew link --overwrite cocoapods

works for me

sudo gem install cocoapods

Works for me

brew reinstall cocoapods
brew link --overwrite cocoapods

works for me

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

This solution works for me. Thanks. By the way, my Mac Version is 10.15.5 macOS Catalina.

Try this to get cocoapods works on macOS Catalina.. This worked for me..

$ brew cleanup -d -v    
$ brew install cocoapods

To force the link and overwrite all conflicting files:

$ brew link --overwrite cocoapods

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

This worked for me 👍

Worked out using: brew install cocoapods --build-from-source
then: brew link --overwrite cocoapods

I did this but I also was prompted to install XCode Command line tools. This did the trick for me!

I know this is old, and closed, but this might help someone. The issue for me was that I had messed with my ruby installation a while back and had rvm installed. So this is what resolved this issue for me:

  1. removed all of my ruby env variables from my .zshrc (eg export PATH="$PATH:$HOME/.rvm/bin")
  2. restart iTerm/Terminal
  3. removed rvm using rvm implode and rm -rf ~/.rvm
  4. restart iTerm/Terminal
  5. finally pod install worked
Was this page helpful?
0 / 5 - 0 ratings

Related issues

evermeer picture evermeer  ·  3Comments

Mingmingmew picture Mingmingmew  ·  3Comments

intelliot picture intelliot  ·  3Comments

luhui picture luhui  ·  3Comments

pronebird picture pronebird  ·  3Comments