ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚑️
https://capacitorjs.com
MIT License
12.14k stars 1.01k forks source link

bug: @capacitor/android: 3.4.3 - ERR_SUBPROCESS_COMMAND_NOT_FOUND #5545

Closed codeconsole closed 2 years ago

codeconsole commented 2 years ago

Bug Report ERR_SUBPROCESS_COMMAND_NOT_FOUND

What command is it looking for? Perhaps the error should specify?

Capacitor Version

% npx cap doctor android 
πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

  @capacitor/cli: 3.4.3
  @capacitor/core: 3.4.3
  @capacitor/android: 3.4.3
  @capacitor/ios: 3.4.3

Installed Dependencies:

  @capacitor/cli: 3.4.3
  @capacitor/core: 3.4.3
  @capacitor/android: 3.4.3
  @capacitor/ios: 3.4.3

Platform(s)

@capacitor/android: 3.4.3

Current Behavior

% npx cap run android
βœ” Copying web assets from www to android/app/src/main/assets/public in 9.85ms
βœ” Creating capacitor.config.json in android/app/src/main/assets in 1.07ms
βœ” copy android in 16.39ms
βœ” Updating Android plugins in 1.16ms
[info] Found 3 Capacitor plugins for android:
       @capacitor/camera@1.3.1
       @capacitor/filesystem@1.1.0
       @capacitor/geolocation@1.3.1
βœ” update android in 28.55ms
βœ– Running Gradle build - failed!
[error] ERR_SUBPROCESS_COMMAND_NOT_FOUND

Expected Behavior

Expect the app to run in the emulator

Code Reproduction

https://github.com/codeconsole/exiftest/tree/capacitor

Other Technical Details

npm --version output: 8.5.5

node --version output: v17.8.0

pod --version output (iOS issues only): 1.11.2

Additional Context

% cd android
% ./gradlew assembleDebug 

BUILD SUCCESSFUL in 798ms
153 actionable tasks: 153 up-to-date
% npx ionic info

Ionic:

   Ionic CLI : 6.19.0

Capacitor:

   Capacitor CLI      : 3.4.3
   @capacitor/android : 3.4.3
   @capacitor/core    : 3.4.3
   @capacitor/ios     : 3.4.3

Utility:

   cordova-res : not installed globally
   native-run  : 1.5.0

System:

   NodeJS : v17.8.0 (/opt/homebrew/Cellar/node/17.8.0/bin/node)
   npm    : 8.5.5
   OS     : macOS Monterey
% sw_vers
ProductName:    macOS
ProductVersion: 12.3
BuildVersion:   21E230
% sysctl -a | grep brand    
machdep.cpu.brand_string: Apple M1 Pro
codeconsole commented 2 years ago

Related? https://github.com/ionic-team/capacitor/discussions/5530

codeconsole commented 2 years ago

Using Node installed with nodenv works, but I don't understand why the brew installation doesn't. capactitor seems to be the only cli that has issues using the brew installed version.

Temporary Solution - Use nodenv

% brew uninstall node
% brew install nodenv 
% echo 'export PATH=${PATH}:~/.nodenv/shims' >> ~/.zprofile 
% nodenv install 17.7.2
% nodenv global 17.7.2

% npx cap run android
βœ” Copying web assets from www to android/app/src/main/assets/public in 7.48ms
βœ” Creating capacitor.config.json in android/app/src/main/assets in 745.25ΞΌs
βœ” copy android in 12.87ms
βœ” Updating Android plugins in 3.42ms
[info] Found 3 Capacitor plugins for android:
       @capacitor/camera@1.3.1
       @capacitor/filesystem@1.1.0
       @capacitor/geolocation@1.3.1
βœ” update android in 32.04ms
βœ” Running Gradle build in 1.32s
βœ” Deploying app-debug.apk to emulator-5554 in 1.88s
random-rage commented 2 years ago

Using Node installed with nodenv works, but I don't understand why the brew installation doesn't. capactitor seems to be the only cli that has issues using the brew installed version.

% brew uninstall node
% brew install nodenv 
% echo 'export PATH=${PATH}:~/.nodenv/shims' >> ~/.zprofile 
% nodenv install 17.7.2
% nodenv global 17.7.2

% npx cap run android
βœ” Copying web assets from www to android/app/src/main/assets/public in 7.48ms
βœ” Creating capacitor.config.json in android/app/src/main/assets in 745.25ΞΌs
βœ” copy android in 12.87ms
βœ” Updating Android plugins in 3.42ms
[info] Found 3 Capacitor plugins for android:
       @capacitor/camera@1.3.1
       @capacitor/filesystem@1.1.0
       @capacitor/geolocation@1.3.1
βœ” update android in 32.04ms
βœ” Running Gradle build in 1.32s
βœ” Deploying app-debug.apk to emulator-5554 in 1.88s

Because brew does not install expect utility? And script can't spawn process

codeconsole commented 2 years ago

Because brew does not install expect utility? And script can't spawn process

@random-rage no, that's not it. I can confirm expect exists and works and switching back to the brew installation does not work.

% nodenv uninstall 17.7.2
% nodenv uninstall 16.14.2
% brew install node
% npx cap run android
βœ” Copying web assets from www to android/app/src/main/assets/public in 6.59ms
βœ” Creating capacitor.config.json in android/app/src/main/assets in 757.79ΞΌs
βœ” copy android in 11.18ms
βœ” Updating Android plugins in 1.37ms
[info] Found 3 Capacitor plugins for android:
       @capacitor/camera@1.3.1
       @capacitor/filesystem@1.1.0
       @capacitor/geolocation@1.3.1
βœ” update android in 22.13ms
βœ– Running Gradle build - failed!
[error] ERR_SUBPROCESS_COMMAND_NOT_FOUND

% which expect
/usr/bin/expect
% expect
expect1.1> 
butaminas commented 2 years ago

I have the same issue and I have noted it here and I can confirm that I was using node from brew from a long time now without a problem and only just recently, something happened and I'm getting ERR_SUBPROCESS_COMMAND_NOT_FOUND when trying to run on android.

codeconsole commented 2 years ago

@butaminas I have been using brew node for on a long time with my other MacBook. I only started having this issue when I tried a MacBook with an M1 chip. Are you using the same computer/os as the one that was previosuly working?

butaminas commented 2 years ago

@codeconsole yes and it's an intel mac, therefore, I doubt that it's M1 related.

The suggestion to delete node and install it via nodenv did fix the problem for me. However, I had to do a couple more steps to manually delete node like so as brew uninstall node was not enough:

brew uninstall node;
which node;
sudo rm -rf /usr/local/bin/node;
sudo rm -rf /usr/local/lib/node_modules/npm/;
brew doctor;
brew cleanup --prune-prefix;

Anyway, it was working with the regular brew node on an intel mac with the latest MacOS so I'm really confused about what exactly happened that made it stop working. My only idea for now is that I did brew update and it updated node and this somehow corrupted the node installation on the system.

ruialves2017 commented 2 years ago

https://github.com/ionic-team/capacitor/issues/5545#issuecomment-1082035246

Worked for me

MatthewAlner commented 2 years ago

So this happened to me on my Intel mac using brews node@16 both after brew updates weirdly for other packages... I think maybe ffmpeg, you can get better output if you call without npx it like this ionic capacitor run android --verbose

That says capacitor:android:run Invoking ./gradlew with args: [ 'assembleDebug' ] is what's failing but calling gradlew manually works.

I can confirm that switching to nodenv works I went with node LTS though 16.14.2, below where my steps. I'd love to know what the real issue here was.

brew uninstall node@16
brew install nodenv
echo 'export PATH=${PATH}:~/.nodenv/shims' >> ~/.zshrc
nodenv install 16.14.2
nodenv global 16.14.2
node --version
ionic capacitor run android
joeyk16 commented 2 years ago

I hope this helps someone. I had this issue 2 times now. I think its because my brew updated my node version to v17. When I ran node -v it returned v17.... I forgot exactly what eversion but it was 17. When I run ionic cap run android -l --external I eventually get the following error:

βœ– Running Gradle build - failed!
[error] ERR_SUBPROCESS_COMMAND_NOT_FOUND

Here is what I did:

1) I installed nvm 2) I ran nvm use stable 3) When I run node -v it returns v14.17.6

Now when I run ionic cap run android -l --external it works perfectly

codeconsole commented 2 years ago

@joeyk16 not sure why you want to run such an old version, my solution works fine with 17.7.2 v14.17.6 is wicked old.

jcesarmobile commented 2 years ago

There seems to be some weird bug on the nodejs installed from homebrew (not only 17, I've seen it on 16 and 14 too, 12 worked fine)

I've created a gist with a simplification of the code that is failing, and it's nodejs spawn behaving differently on the homebrew node installs when running the gradle file, it calls the error function with ENOENT and the close function with -2 code, but the gradle execution finished correctly with

BUILD SUCCESSFUL in 490ms 1 actionable task: 1 executed

When using node from nvm/nodenv it doesn't call the error function and the close is called with code 0

carlocab commented 2 years ago

As noted in https://github.com/Homebrew/homebrew-core/issues/99688, this is a bug in libuv. Will be fixed in https://github.com/Homebrew/homebrew-core/pull/99801.

jcesarmobile commented 2 years ago

Should be fixed by a

brew update && brew upgrade libuv

ionitron-bot[bot] commented 1 year ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.