Closed devophyte closed 1 year ago
To ensure CDPATH was not a factor I unset it. Now I get an error when initializing a new project:
unset CDPATH
npx react-native init Test2
###### ######
### #### #### ###
## ### ### ##
## #### ##
## #### ##
## ## ## ##
## ### ### ##
## ######################## ##
###### ### ### ######
### ## ## ## ## ###
### ## ### #### ### ## ###
## #### ######## #### ##
## ### ########## ### ##
## #### ######## #### ##
### ## ### #### ### ## ###
### ## ## ## ## ###
###### ### ### ######
## ######################## ##
## ### ### ##
## ## ## ##
## #### ##
## #### ##
## ### ### ##
### #### #### ###
###### ######
Welcome to React Native!
Learn once, write anywhere
✔ Downloading template
✔ Copying template
✔ Processing template
✔ Installing Bundler
✖ Installing CocoaPods dependencies (this may take a few minutes)
error warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
✖ Installing CocoaPods dependencies (this may take a few minutes)
error Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
Error: Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
at createFromTemplate (/Users/developer/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:169:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.initialize [as func] (/Users/developer/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:222:3)
at async Command.handleAction (/Users/developer/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/index.js:140:9)
info Run CLI with --verbose flag for more details.
Tell me this isn't weird.
So I shutdown the simulator, opened a new shell session keeping the CDPATH, and ran the above code again -- it worked 🥰
So I delete the project (rm -rf Test Test2
), unset the CDPATH, and ran again. It also worked. -- weird
After building, I opened a new terminal session and just started everything up with CDPATH (on the project I created without CDPATH) just to see if it would complain. It ran without issue.
Is it common for React (perhaps on lower performing devices) to have init errors?
Ran through the whole init/start/build phase one more time, again with CDPATH and the startup passes but the build fails again (like the initial post) pointing to the generate-specs-cli.js in another project directory on the CDPATH. 🤬
Kind of interested to hear if someone has thoughts. I've cleared out the ~/.../DerivedData/* directories and files between builds to ensure that wasn't a conflict.
It seems inconsistent and I haven't narrowed down if the CDPATH matters at all, or if it matters during a particular phase. For instance, maybe it's important not to have it during the react-native init
, but then it doesn't matter during the yarn iOS
?
yarn ios
two more times with CDPATH set and it encountered build failureunset CDPATH
and it worked bundled and loaded -- once it bundles the first time it doesn't seem to matter; it builds with the path setI modified the full path of the CDPATH above.
Let's say it was failing to find this file:
~/node/projects/sails/scripts/generate-specs-cli.js
scripts
directory doesn't existI'd be running the yarn from a directory that looked like this:
~/node/projects/temp/react/native/<ProjectName>
This shouldn't matter much, but shows sails/ is at the same level as native/'s great grandparent and a great-great grandparent from the project:
pwd # .../native/Foo
ls -l ../../../../sails/
I don't think anything would be using a relative path that deep and I don't think relativity is a factor, since it seems the population of $CDPATH is the big influencer here; again, despite that "scripts" directory not existing on the PATH or CDPATH.
The issue may have been related to exporting CDPATH. I intentionally export
ed CDPATH, adding it to my .bashrc many years ago and I'm not sure why. Maybe I did it for csh or maybe out of ignorance I copied the formatting of the PATH export?
General online recommendations are not to export CDPATH as they may interfere with commands on the command line, which is what is occuring. This is the first time after decades that it has interfered with anything.
Also interesting, in the ruby gems that come loaded with react-native project's (i.e. vendor/bundle/ruby/2.7.0/gems) there are many files that intentionally delete or unset CDPATH. I'm guessing something in the react-native ios pipeline also needs to clear out the environment variable as a precaution.
TestProject/vendor/bundle/ruby/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/installer/pod_source_preparer.rb:62:
ENV.delete('CDPATH')
TestProject/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/man/Makefile.in:76:
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
TestProject/vendor/bundle/ruby/2.7.0/gems/ffi-1.15.5/ext/ffi_c/libffi/ltmain.sh:144:
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
...
It seems Expo is good about it too:
~/.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/build/commands/utils/CreateApp.js:184:
const cdPath = path().relative(process.cwd(), projectRoot);
~/.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/build/commands/utils/CreateApp.js:185:
if (cdPath.length <= projectRoot.length) {
~/.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/build/commands/utils/CreateApp.js:186:
return cdPath;
~/.nvm/versions/node/v18.12.1/lib/node_modules/expo-cli/build/commands/initAsync.js:385:
const cdPat = CreateApp().getChangeDirectoryPath(projectRoot);
...
I've re-run the creation scripts with CDPATH set, but not exported and I think the issue is resolved.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
Oh my. @devophyte you're my hero for the day. I also had set (and forgot about) CDPATH
in my .zshrc
, causing the same issue.
The fix in my case:
$ unset CDPATH
$ rm -rf ~/Library/Developer/Xcode/DerivedData/
$ rm -rf ios
$ npm run ios
Unbelievable! unset CDPATH
did work for me also .-.
Description
Not sure this is a bug. I'm new to React Native and encountered build errors. I switched to using Expo, which worked, but wanted to figure out what it is that is interfering with a vanilla install of React on a hardly used MacBook Air.
Fresh install of Xcode 14.2 and Command Line Tools for Xcode.
The project creates,
yarn start
spins up Metro, butyarn ios
encounters an error during the build process.BuildError.log
Version
0.70.6
Output of
npx react-native info
Steps to reproduce
Terminal 1
Terminal 2
Snack, code example, screenshot, or link to a repository
None.
Comments / Interesting Discoveries
Something odd (found in the attached log) is an error that seems to be pointing to a .js file in an unrelated node project. On this machine the only reason I can think that it would search there would be due to overloading the CDPATH (i.e.
export CDPATH=~/node-apps/sails:$CDPATH
) in ~/.bashrcRemoving that from the equation (
unset CDPATH
) and a build error still occurs.Oddly, I ran it again and build error with output too long, so went to redirect to a file (
> BuildError.log
) then quickly noticed that was going to log standard output, so issued a Command+C to quit the process and (2> BuildError.log
) to capture the error messages. What happened? ... it ran successfully?I have no idea what's going on.
That's the STDOUT output. The BuildError.log is a bunch of build and expected output, but I don't get why it worked this time after a few failures. I'm going to walk through the steps again.