Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pod install fails due to glog #25561

Closed
chrisspankroy opened this issue Jul 9, 2019 · 81 comments
Closed

pod install fails due to glog #25561

chrisspankroy opened this issue Jul 9, 2019 · 81 comments
Labels
Bug Resolution: Locked This issue was locked by the bot.

Comments

@chrisspankroy
Copy link

chrisspankroy commented Jul 9, 2019

When running pod install in my project, it fails with the error:
error: C compiler cannot create executables
Screen Shot 2019-07-09 at 4 13 34 PM

React Native version: 0.60.0

System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 4.15 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node
    Yarn: 1.16.0 - ~/.yarn/bin/yarn
    npm: 6.9.1 - ~/.nvm/versions/node/v8.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 11.0/11M362v - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.0 => 0.60.0
  npmGlobalPackages:
    eslint-plugin-react-native: 3.7.0

I can also reproduce this when not using the beta SDK:

System:
    OS: macOS 10.15
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 4.04 GB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 8.16.0 - ~/.nvm/versions/node/v8.16.0/bin/node
    Yarn: 1.16.0 - ~/.yarn/bin/yarn
    npm: 6.9.1 - ~/.nvm/versions/node/v8.16.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    Android SDK:
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.0 => 0.60.0
  npmGlobalPackages:
    eslint-plugin-react-native: 3.7.0

Steps To Reproduce

I found this issue when running pod install in my pre-existing project that I have upgraded to RN 0.60. But, I can reproduce the exact same error when running react-native init test and the error occurs when it gets to pod install

Describe what you expected to happen:
The script not to crash and pod install to finish running

Snack, code example, or link to a repository:
Just do react-native init test and it gives the error

@chrisspankroy
Copy link
Author

This error is the same as #25532, but that issue wasn't formatted well and I couldn't tell what was going on

@chrisspankroy
Copy link
Author

Looking further into this, the script that is being run is at:
/node_modules/react-native/scripts/ios-configure-glog.sh

If you want to run that script manually, you need to unpack glog-0.3.5 by running
cd node_modules/react-native/scripts/ && ./ios-install-third-party.sh, then copy the configure script into third-party/glog-0.3.5:
cp ios-configure-glog.sh third-party/glog-0.3.5
Then you can run the script and see the crash by running
cd third-party/glog-0.3.5 && ./ios-configure-glog.sh
Screen Shot 2019-07-09 at 4 29 09 PM

@panyar
Copy link

panyar commented Jul 10, 2019

Hi @chrisspankroy
I have the same issue here. Run gem update xcodeproj fix this issue. Hope that will work out for you too.

@chrisspankroy
Copy link
Author

@panyar That did not work for me. Thanks though

@IgorDePaula
Copy link

Not work for me too. =/

@ghost
Copy link

ghost commented Jul 12, 2019

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

@chrisspankroy
Copy link
Author

That did not work for me

@donCarlosOne
Copy link

any luck with this? i'm having the exact same issue on macOS 10.14.6/Xcode 10.3/RN 0.60

@IgorDePaula
Copy link

I have, is necessary update pod before install dependencies pods on react native.

@cchamb-gh
Copy link

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

@skailasa
Copy link

skailasa commented Sep 2, 2019

That did not work for me

Did you manage to find a solution? Ive tried the above and have this same issue.

@chrisspankroy
Copy link
Author

Not yet :/

@skailasa
Copy link

skailasa commented Sep 4, 2019

Not really a proper fix, but for future reference to others searching, I found that it was almost certainly due to the way Cocoapods is installed by react-native. I installed Cocoapods separately and after that the bootstrap/build commands started to work for me. (Specifically, I tried another framework (nativescript) and installed Cocoapods using their install script - after which everything worked)

@chrisspankroy
Copy link
Author

I tried running NativeScript's install script and it did not fix it :(

@skailasa
Copy link

skailasa commented Sep 5, 2019

Did the Cocoapods install definitely succeed? It doesnt have to be through Nativescript's installer I don't think.

@chrisspankroy
Copy link
Author

Yeah, I’ve made sure it succeeds. I’ve ran CocoaPods’s own installer too and nothing

@BelinChung
Copy link

This looks like a problem with glog or my environment.
I was download glog and try to install it separately.
When I run ./configure under the glog folder, there is the same problem as react-native project.

Finally, I found a way to solve the failure of installing glog, just run install script as root, sudo ./configure

Unfortunately, pod install does not support running as root.

@i-am-lioness
Copy link

I am still having this issue

@i-am-lioness
Copy link

update

This was my error output:
Screen Shot 2019-09-22 at 1 03 04 AM

The important part was
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib

I resolved it by following these instructions (from https://stackoverflow.com/questions/54261455/library-not-loaded-usr-local-opt-readline-lib-libreadline-7-dylib):
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib

@yaizudamashii
Copy link

@BelinChung I'm facing the exact same issue, it seems that my glog requires sudo to configure and make. Because of that pod install always fails. I've downgraded react native from 0.60.5 to 0.59.10 and the same issue persists, I've uninstalled and reinstalled different versions of Xcode (11, 10.3, 10.1) and they all seem to fail.

@chrisspankroy
Copy link
Author

Just an update:
I still haven’t found a solution to this, but adding sudo to the configure script to get it to work isn’t a solution. Sure it might get the configure script to work, but it messes up your file permissions and doesn’t even help solve the actual problem :/

@BelinChung
Copy link

Update:
🎉 Good news here, It seems that react-native@0.61.1 solves this problem. Official init demo is working for me now.

@chrisspankroy
Copy link
Author

Updating to 0.61.1 did not work for me :(

@yaizudamashii
Copy link

I tried react-native getting started's React Native CLI Quickstart for MacOS for iOS
https://facebook.github.io/react-native/docs/getting-started.html
and confirm that AwesomeProject did not install, again because of glog

@yaizudamashii
Copy link

So I experimented and found out something that allowed me to install the example AwesomeProject. I created a new user on Mac and made the user admin. Then I logged out my normal user account and logged in as the new user, and followed the instructions. The example app failed to install at installing the pods state, but not for the same reason as my main user. Then I did sudo xcode-select --reset and did pod install and it worked!

I tried sudo xcode-select --reset with my normal user account and I am still failing with installing glog however.

@yaizudamashii
Copy link

@chrisspankroy
I figured it out. It is the environment variables. I had LDFLAGS and CPPFLAGS set. After unsetting those, the pod installation worked.

@chrisspankroy
Copy link
Author

Whoop, whoop, that finally worked! Great job, I'll close the issue now. Feel free to reopen if this comes up again

@prasanth1216
Copy link

I faced a similar issue with Flipper-GLog dependency, I was using macOS Catalina (with XCode 11)
Below steps helped me to resolve this issue:

  1. Rename the Xcode app name, make sure the app name does not include space character.(Xcode 11.app to Xcode11.app)
  2. Switch to the Xcode with sudo xcode-select --switch
    sudo xcode-select -switch /Applications/Xcode11.app/
  3. Pod install

@xgqfrms
Copy link

xgqfrms commented Jun 30, 2020

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

it's not working

image

@waqas0ahmad
Copy link

I am using windows and getting this problem after this
image

@weblancaster
Copy link

For anyone that ends up here and has the same issue I had (error log below).

I got a brand new MacBook Pro and started having the issue below on react-native fresh install when trying to run pod install but after following this comment things got back to normal.

[!] /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/"

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-apple-darwin-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for arm-apple-darwin-gcc... /Library/Developer/CommandLineTools/usr/bin/cc -arch armv7 -isysroot
checking whether the C compiler works... no
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: SDK "iphoneos" cannot be located
xcrun: error: unable to lookup item 'Path' in SDK 'iphoneos'
/Users/michaellancaster/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing: Unknown `--is-lightweight' option
Try `/Users/michaellancaster/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
configure: error: in `/Users/michaellancaster/Library/Caches/CocoaPods/Pods/Release/Flipper-Glog/0.3.6-1dfd6':
configure: error: C compiler cannot create executables
See `config.log' for more details

@parnekov
Copy link

Seems to be an issue with Xcode after a new install. I resolved this issue on my machine by:

  1. launch Xcode
  2. from Xcode menu, select Preferences
  3. select Locations tab
  4. select a value for Command Line Tools. Mine was previously blank.

This assumes you've already got command line tools installed.

You may be able to achieve the same result from xcode-select on the command line, but I didn't try that.

Solved

@Valegox
Copy link

Valegox commented Aug 28, 2020

I have exactly the same issue and I tried each solution, except unsetting LDFLAGS and CPPFLAGS variables because I don't find them. I searched in ~/.bashrc, ~/.bash_profile, and ~/.profile. I don't use zsh, but should I install it ? Thanks for your help.

@Valegox
Copy link

Valegox commented Aug 29, 2020

I solved the problem with $ sudo xcode-select --switch /Applications/Xcode.app. Important: restart your terminal after executing this command ! Then you can do cd ios && pod install

@BiplovQss
Copy link

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

thanks a lot. It helped.

@coawazie
Copy link

Restarting my computer then run pod install again fixed the problem for me. It should be noted that I did run sudo xcode-select --switch /Applications/Xcode.app first.

Thanks! This worked for me

@lancejpollard
Copy link

Removing LDFLAGS and CPPFLAGS fixed it for me!

@0x5e
Copy link

0x5e commented Jan 19, 2021

@lancejpollard works for me. My ~/.zshrc added env for llvm things before.

@tasdendu
Copy link

tasdendu commented Feb 9, 2021

As per #18408 (comment) (thanks @YuryKorovko !)

sudo xcode-select --switch /Applications/Xcode.app
cd ios && pod install

Fixed!

This solution works perfectly for me. Thanks @ghost.

@keshav100
Copy link

sudo xcode-select --switch /Applications/Xcode.app

Worked for me no restart needed

worked for me

@luckieee
Copy link

luckieee commented May 9, 2021

It didn't work any of the solutions above described. still it's laughing on me with the error
error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template. Please try again manually: "cd ./myapp/ios && pod install".
even i follow sudo xcode-select --switch /Applications/Xcode.app and restart then cd ./myapp/ios && pod install also [!] Oh no, an error occurred.

what can i do? i started working in new Mac there is no below environmental variables
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

I had chosen even XCode CLI tools in preferences -> locations -> command line tools (my version Xcode 12.4 (12D4e))

@dalu-ao
Copy link

dalu-ao commented Jul 9, 2021

Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template.
Please try again manually: "cd ./demoApp/ios && pod install".

Can anyone else suggest something to fix this?

@iftheshoefritz
Copy link

Nothing discussed so far worked for me (xcode-select, removing existing compiler flags). However I managed to make pod install succeed with some fairly extreme hacking in my node_modules folder.

When I check the temp directory referenced I see an old config.sub from 2007, which can't handle this command in scripts/ios-configure-glog.sh: ./configure --host arm-apple-darwin

In my project I can hack that script under node_modules/react-native/scripts to add this line:

cp path/to/modern/config.sub config.sub

Immediately above the line: ./configure --host arm-apple-darwin

After doing that, pod install progressed beyond glog.

Now, I am curious about where the config.sub in my node modules came from that it is so out of date (despite having run yarn install no earlier than April 2021 when I received this machine). I copied my version from the configured source of Ruby 3, which seems ridiculously hacky.

@ntrabue
Copy link

ntrabue commented Jul 22, 2021

I tried pretty much everything in this thread. I had a value for LDFLAGS and CFLAGS in my .zshrc updating those values finally let me get through pod-install

# old values
# export LDFLAGS="-L $(xcrun --show-sdk-path)/usr/lib"
# export CFLAGS="-L $(xcrun --show-sdk-path)/usr/include"

# new values
export LDFLAGS="-L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include"

@sleaper
Copy link

sleaper commented Jul 23, 2021

I got a lot of glog errors not during pod install, but after npx react-native run-ios. I tried everything in this thread, but nothing helps.

@dalu-ao
Copy link

dalu-ao commented Jul 23, 2021

Are you on an m1 mac?

@sleaper
Copy link

sleaper commented Jul 23, 2021

Yes, I'm using MacBook Air m1 2020

@dalu-ao
Copy link

dalu-ao commented Jul 23, 2021

Ohh, I had the same problem, you're going to have to disable flipper and use rosetta. [https://stackoverflow.com/questions/66612257/build-error-of-react-native-run-ios-on-m1-macbook]

@dalu-ao
Copy link

dalu-ao commented Jul 23, 2021

@sleaper Tell me if that works for you

@sleaper
Copy link

sleaper commented Jul 23, 2021

@dalu-ao Now I got new error:
Screenshot 2021-07-23 at 14 01 07

Now is problem with React yoga?

@dalu-ao
Copy link

dalu-ao commented Jul 23, 2021

Okay, I'm not super sure. But you can try uninstalling cocoa pods, then installing cocoa pods with brew. [(https://superuser.com/questions/686317/how-to-fully-uninstall-the-cocoapods-from-the-mac-machine)
If it says you don't have permissions use the sudo command. Then install with brew using brew install cocoapods.

i got that same error but I'm not sure how I solved it, try what I said above

@sleaper
Copy link

sleaper commented Jul 23, 2021

@dalu-ao I installed the Xcode 12.5.1 instead of Xcode 13 beta, reinstall Cocoapods and it works. Thank you very much for your kind help sir.

@AyoubXwire
Copy link

If you are using Xcode beta use the command and add (-beta) like this:

sudo xcode-select --switch /Applications/Xcode-beta.app
cd ios && pod install

@facebook facebook locked as resolved and limited conversation to collaborators Oct 10, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests