Open c0d3x opened 2 years ago
Hi @c0d3x, this is something we've seen, but haven't been able to reliably reproduce every time. See #1007 for more discussion. For some reason, when React Native starts its shell, changing something that causes Volta to look in the wrong place for platform information.
Within the terminal spawned by npm run ios
, can you share what $HOME
and $VOLTA_HOME
are set to, if anything? Also, what does cwd
output, is that different from the project directory?
Encountered on an initially setup macOS 12.6.1
mylib
yarn example android
cd example/android
./gradlew
failed while ./gradlew --no-daemon
work$ ./gradlew
:ReactNative:Unexpected empty result of running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command.
:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/longxiang/mylib/example/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> Volta error: Node is not available.To run any Node command, first set a default version using `volta install node`Error details written to /Users/longxiang/.volta/log/volta-error-2022-11-19_15_48_25.370.log
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 25s
$ ./gradlew --no-daemon
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.5.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build
> Task :help
Welcome to Gradle 7.5.1.
To run a build, run gradlew <task> ...
To see a list of available tasks, run gradlew tasks
To see more detail about a task, run gradlew help --task <task>
To see a list of command-line options, run gradlew --help
For more detail on using Gradle, see https://docs.gradle.org/7.5.1/userguide/command_line_interface.html
For troubleshooting, visit https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 13s
6 actionable tasks: 1 executed, 5 up-to-date
BTW, ln -s ~/.volta/bin/node /usr/local/bin/node
and REBOOT
don't help either
Thank you for the super details repro steps @Sunbreak! I'm not on a Mac machine at the moment, but I'll definitely look to try those out as soon as I can, to see if I can understand what exactly is getting disconnected in this case.
I am having the same issue, but via a Fastlane build. The solutions provided in the linked issue did not provide a solution for me.
Fastlane cli output:
bundler: failed to load command: fastlane (/Users/xxx/Development/xxx/app/vendor/bundle/ruby/2.7.0/bin/fastlane)
FastlaneCore::Interface::FastlaneShellError: [!] Exit status of command '/Users/xxx/Development/xxx/app/android/gradlew clean -p /Users/xxx/Development/xxx/app/android' was 1 instead of 0.
:ReactNative:Unexpected empty result of running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command.
:ReactNative:Running '[node, -e, try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}]' command failed.
FAILURE: Build failed with an exception.
* Where:
Script '/Users/xxx/Development/xxx/app/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 413
* What went wrong:
A problem occurred evaluating script.
> Volta error: Node is not available.To run any Node command, first set a default version using `volta install node`Error details written to /Users/xxx/.volta/log/volta-error-2023-02-22_17_12_22.698.log
Volta error log:
"node" "-e" "try {console.log(require(\'@react-native-community/cli\').bin);} catch (e) {console.log(require(\'react-native/cli\').bin);}"
Volta v1.1.1
Node is not available.
To run any Node command, first set a default version using `volta install node`
Error cause: Resource temporarily unavailable (os error 35)
Run Android build
- STOP
yarn example android
cd example/android
./gradlew
failed while./gradlew --no-daemon
work
Fastlane was actually calling ./gradlew
command. Try add --no-daemon
@Sunbreak Thank you very much for the quick reply. I tried your solution, and it works.
To reproduce it with cli use: ./android/gradlew bundleRelease --project-dir ./android
To fix it with cli use the no daemon param: ./android/gradlew bundleRelease --project-dir ./android --no-daemon
With Fastlane pass the no daemon param via flags:
gradle(
task: 'bundleRelease'
project_dir: File.absolute_path('../android'),
flags: "--no-daemon"
)
Thanks!
Sporadically also getting this error.
Cant put my finger on it, but it seems to occur when I open VS-Code BEFORE opening the terminal app.
Rebooting my computer helped.
(Also ran volta setup
and unset _VOLTA_TOOL_RECURSION in each
before reboot)
Running pkill -f '.*GradleDaemon.*'
whenever I encounter it does the trick.
Running
pkill -f '.*GradleDaemon.*'
whenever I encounter it does the trick.
./gradlew --stop
is enough, especially for Windows
Running
pkill -f '.*GradleDaemon.*'
whenever I encounter it does the trick.
This worked for me on my M3 Mac
Literally tried all the other suggestions on here. I also have this in my .zshrc
, .bashrc
, and .profile
files.
export VOLTA_HOME=$HOME/.volta
export PATH=$VOLTA_HOME/bin:$PATH
unset _VOLTA_TOOL_RECURSION in each
Setup: Mac OS 12.6 running on Apple M1 Max chip. Terminal: iTerm 2 with ZSH
When developing react-native apps, and I run
./gradlew clean
in/MyProject/android/
folder, I get this message. Or when I try to start ios withnpm run ios
, the terminal that pops up also is unable to start metro because volta is missing a default node ref.The log file contains this info:
Running
volta list
in same folder (/MyProject/android/) I get this:Content within platform.json
.zshrc config:
PATH output
Volta path:
Node path:
What is the problem here? How can I resolve this?