facebook/react-native

"config.h" file not found on a CI platform

GuillaumeNachury opened this issue ยท 13 comments

Figthing this issue for several RN versions, I still haven't found a way to solve this.
The main constraint is that I'm using a CI platform to build my apps where I can't do manual tasks.

The issue:

  1. I create a new RN project
    react-native init aProject

  2. Push my code to the CI platform and request an iOS build
    Notice that the CI uses a fresh workspace at every build, so no need to rm -Rf node_modules before the npm i
    I also clean the .rncache at each build

Result :
3. Build failed because of "config.h" file not found from mutex.h

Important point

I do have the same issue locally but I use an ugly workaround by copying the glog-0.3.4 folder from a very old RN project...

Environment:
OS: macOS Sierra 10.12
Node: 8.4.0
Yarn: 0.27.5
npm: 5.4.0
Watchman: 4.7.0
Xcode: Xcode 8.3

react-native: 0.48.3
react: 16.0.0-alpha.12

Find a solution?

@GuillaumeNachury Same issue for me, what is your solution?

@mileung , @silentcloud
Actually, on my CI server there was multiple instances of Xcode and some have the version as a suffix e.g. /Applications/Xcode9 /Applications/Xcode7.3 /Applications/Xcode 8.3 ...
I was targeting the 8.3 one.

But I discover that if the path to Xcode OR to your project contains a space (notice the space between Xcode and 8.3 you cannot compile the thirdparty / your project.

I just made sure that no space was used in any of the path of my tools / project env.

Hope it'll help.

G.

Interesting. I actually just ran react-native upgrade and that fixed my issue

@GuillaumeNachury, any solution i am still getting this error every time when i try to create new project using react-native init <project_name>

Version:
React-native: 0.52.0

Any solutions?

Am having the same issue with new project, path does not have spaces or special characters in it and I kept it (relavtively) short: /Users/username/dev/test
Using react-native@0.53.0 and react@16.2.0.
Xcode.app also does not have spaces in it and there is only one version installed.

react-native run-ios fails with:

../third-party/glog-0.3.4/src/base/mutex.h:105:10: fatal error: 'config.h' file not found
#include "config.h"           // to figure out pthreads support
         ^~~~~~~~~~
1 error generated.

** BUILD FAILED **

Very frustrating, if I don't get this fixed soon I will need to switch to a different framework (tried different version of react-native as well, as far back as 0.42).

Update:
I even removed and reinstalled Xcode to make sure but am still getting the same issue.

@mweitzel2005 possible reference to #14382.

Ignigena answer :
"**Running into the same issue here after upgrading from 0.44. None of the above solutions or clearing caches did the trick for me. Here's what I did to get things working again:

In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder, run ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find**"

do the trick for me

if it does not help for you, you can remove third-party from /node_modules/react-native/ - it should help

Running the script above directly did also not work for me. For me this seems to have been related to an issue with the awk tool on mac OS Sierra (can't upgrade to High Sierra due to company policy). I used brew install gawk and brew link gawk to fix the issue for me.

id77 commented

Possible Causes "unsafe absolute working directory name"

Solution:

  1. Try letter naming folder
  2. Run rm -rf ./ios/build && react-native run-ios
  1. Remove node modules folder
  2. yarn install
  3. pod install in iOS folder

@mweitzel2005 possible reference to #14382.

Ignigena answer :
"**Running into the same issue here after upgrading from 0.44. None of the above solutions or clearing caches did the trick for me. Here's what I did to get things working again:

In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder, run ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find**"

do the trick for me

if it does not help for you, you can remove third-party from /node_modules/react-native/ - it should help

Thank you! it worked for me!

It seems that when yarn is being used as package manager, the ../../scripts/ios-configure-glog.sh isn't always ran at the right moment.

Perhaps we can add a build stage to the default Xcode project where it checks if the config.h file exists and otherwise run this script?

I'm running into this every once in a while, especially when helping devs set up a project on their own machine, or when trying to run RN builds in a CI.

Someone willing to create a PR for this?