You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2020/07/13 23:54:08 UTC

[GitHub] [cordova-android] mikebridge opened a new issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

mikebridge opened a new issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027


   # Bug Report
   
   ## Problem
   
   When I run the following command in PowerShell on Windows 10, I get an error:
   
   ```
   cordova build android --verbose
   
   => 
   ...
   Running command: C:\MyPath\platforms\android\gradlew cdvBuildDebug -b C:\MyPath\platforms\android\build.gradle
   'sh' is not recognized as an internal or external command,
   operable program or batch file.
   Command finished with error code 1: C:\MyPath\platforms\android\gradlew cdvBuildDebug,-b,C:\MyPath\platforms\android\build.gradle
   C:\MyPath\platforms\android\gradlew: Command failed with exit code 1 Error output:
   'sh' is not recognized as an internal or external command,
   operable program or batch file.
   Error: C:\MyPath\platforms\android\gradlew: Command failed with exit code 1 Error output:
   'sh' is not recognized as an internal or external command,
   operable program or batch file.
       at ChildProcess.whenDone (C:\MyPath\node_modules\cordova-common\src\superspawn.js:135:23)
       at ChildProcess.emit (events.js:315:20)
       at ChildProcess.cp.emit (C:\MyPath\node_modules\cross-spawn\lib\enoent.js:34:29)
       at maybeClose (internal/child_process.js:1021:16)
       at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
   ```
   
   
   ### What is expected to happen?
   
   I am able to run this command on Ubuntu (non-WSL) and it successfully finds the correct version of `gradlew`.  However, in Windows, I think it should find `gradlew.bat`.
   
   ### What does actually happen?
   
   It runs `gradlew` on Windows, rather than `gradlew.bat`
   
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   
   `check_reqs.js` find Android Studio installed in this location: 
   
   ```
   C:\Program Files\Android\Android Studio\gradle\gradle-4.6\bin\gradle
   ```
   
   However, `ProjectBuilder.js` shows this:
   
   ```javascript
   build (opts) {
       var wrapper = path.join(this.root, 'gradlew');
       ...
   ```
   
   It looks to me like there is no attempt to append `.bat` to the filename if it's on Windows.  If I hack this to 'gradlew.bat', it builds successfully.
   
   ### Command or Code
   
   ```
   cordova build android --verbose
   ```
   
   
   ### Environment, Platform, Device
   
   Windows 10
   
   
   ### Version information
   
   Cordova 9.0.0
   It seems to find Android Studio 3.2.1, although I'm not actually using it.
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [X] I searched for existing GitHub issues
   - [X] I updated all Cordova tooling to most recent version
   - [X] I included all the necessary information above
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] EnginKARATAS commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
EnginKARATAS commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1079687710


   I have confirmed "sh" error caused by when emulator not start


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-658303088


   I believe this is a regression from the `shelljs` refactor. I'm assuming `shelljs`, which executed commands as a shell which caused windows to use `PATHEXT`, so windows will automatically find the proper extension for files. Moving to `execa` must simply just use node child processes which does not.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] garethedwards commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
garethedwards commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-979181386


   Found this issue thread while investigating the same " 'sh' is not recognized" occurring on Windows 10 after upgrading to cordova-android.
   
   All the above didn't resolve the issue,  and I was at the point of installing the WSL.
   
   And then... it just worked. And the next time... it didn't.
   
   The difference? I'd opened the emulator, and then closed it.
   
   So it seems, for me at least,  **when the Android Studio emulator isn't running, the 'sh' error occurs.** 
   
   Hope that helps anyone else afflicted with this, and maybe @breautek et al root out the cause or at least catch and issue a more meaningful message
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek edited a comment on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
breautek edited a comment on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-661367245


   This may be more complicated...
   
   I just installed all the dev tools on my windows machine and I was able to build a `cordova-android@9` hello world project without reproducing this issue.
   
   My environment:
   
   ```
   cordova requirements android
   
   Requirements check results for android:
   Java JDK: installed 1.8.0
   Android SDK: installed true
   Android target: installed android-29
   Gradle: installed C:\Users\norman\development\gradle\gradle-6.5.1\bin\gradle.BAT
   
   cordova platform ls
   Installed platforms:
     android 9.0.0
   
   cordova -v
   9.0.0 (cordova-lib@9.0.1)
   
   node -v
   v12.18.2
   ```
   
   Tested on both Command Prompt and Powershell. We may need more information about your environment.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-677738878


   > I have the same issue. My requirements output is:
   > c:\gitroot\ctcmobile>cordova requirements android
   > 
   > Requirements check results for android:
   > Java JDK: installed 1.8.0
   > Android SDK: installed true
   > Android target: installed android-30,android-29,android-28
   > Gradle: installed C:\Gradle\gradle-6.6\bin\gradle.BAT
   > 
   > It seems to try to run the "gradlew" file instead of "gradlew.bat". How can I correct this?
   
   Can you confirm that your `PATHEXT` system variable contains `.BAT`? If not, if you add it, does it solve your issue?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-661367245


   This may be more complicated...
   
   I just installed all the dev tools on my windows machine and I was able to build a `cordova-android@9` hello world project without reproducing this issue.
   
   My environment:
   
   ```
   cordova requirements android
   
   Requirements check results for android:
   Java JDK: installed 1.8.0
   Android SDK: installed true
   Android target: installed android-29
   Gradle: installed C:\Users\norman\development\gradle\gradle-6.5.1\bin\gradle.BAT
   
   cordova platform ls
   Installed platforms:
     android 9.0.0
   
   cordova -v
   9.0.0 (cordova-lib@9.0.1)
   
   node -v
   v12.18.2
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] AyatoKirishima commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
AyatoKirishima commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1041632625


   > I've confirmed the same. 'sh' error without emulator running. Success with emulator running...
   
   Same and i've got `Command failed with exit code 1: apkanalyzer manifest target-sdk` :(


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] LynxTR commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
LynxTR commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1040231088


   I also have confirmed that without emulator running 'sh' error throwed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] avpengage commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
avpengage commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1011172998


   I've confirmed the same.  'sh' error without emulator running.  Success with emulator running...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] AyatoKirishima edited a comment on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
AyatoKirishima edited a comment on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1041632625


   > I've confirmed the same. 'sh' error without emulator running. Success with emulator running...
   
   Same and i've got `Command failed with exit code 1: apkanalyzer manifest target-sdk` :(
   
   It builds but never launch :/


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] LynxTR commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
LynxTR commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1040231088


   I also have confirmed that without emulator running 'sh' error throwed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] killroy42 commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
killroy42 commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-677731623


   I have the same issue. My requirements output is:
   c:\gitroot\ctcmobile>cordova requirements android
   
   Requirements check results for android:
   Java JDK: installed 1.8.0
   Android SDK: installed true
   Android target: installed android-30,android-29,android-28
   Gradle: installed C:\Gradle\gradle-6.6\bin\gradle.BAT
   
   It seems to try to run the "gradlew" file instead of "gradlew.bat". How can I correct this?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] killroy42 commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
killroy42 commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-679003361


   Hmm, in the meantime, I have been able to get it to work both in WSL/Ubuntu and on the windows side on the same machine. I think it mostly boiled down to getting everything into the right folders, etc. Sadly, most of the default install locations and documentation seem to disagree, with `Android`, `android-sdk` and other folders being used interchangeably and never quite explained what they should be, and which set of commands does what exactly. For example, on the WSL/Ubuntu side, I used `apt install`, followed by manually moving things into the home folder after manually changing ownership.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] killroy42 commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
killroy42 commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-677751257


   It's there, I can execute bat files just fine, but the script never tries to.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
breautek commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-677762390


   Thanks, that was kind of my expected response, just wanted to rule it out...
   
   We are using `execa`, which behind the scenes, uses `cross-spawn` for improved windows support, as the native node APIs don't respect `PATHEXT`, which [cross-spawn](https://github.com/moxystudio/node-cross-spawn#why) is suppose to address.
   
   `execa` depends on `cross-spawn@^7.0.0`, and they have been 3 patches, with version `7.0.3` actually have a fix for detecting paths in windows. When I attempted to reproduce this issue, using a fresh install, I was probably testing with the patched version  of `cross-spawn`, and thus could not reproduce the issue.
   
   You can confirm which version you have of `cross-spawn` by looking at `node_modules/cross-spawn/package.json`. The `_id` field should contain `cross-spawn@7.0.3`. If yours contains a lower version, perhaps you're hitting a `cross-spawn` bug.
   
   Running the following commands should make sure all the subdependencies are using the latest satisfiable versions:
   (Forgive me, I don't know the windows equivalent of these commands, so these are based in bash...)
   
   ```
   rm package-lock.json
   rm -rf node_modules
   npm install
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] killroy42 commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
killroy42 commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-685744974


   Ok, it's getting weirder. I started a new project, and it has that problem. Then the old project wouldn't build. But removing the android platform and adding it worked and it builds again. On the new, almost empty project I tried that, I tried what you write, and STILL get the "'sh' is not recognized as an internal or external command," error. This is on the same machine with the same environment set up...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] breautek edited a comment on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
breautek edited a comment on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-661367245


   This may be more complicated...
   
   I just installed all the dev tools on my windows machine and I was able to build a `cordova-android@9` hello world project without reproducing this issue.
   
   My environment:
   
   ```
   cordova requirements android
   
   Requirements check results for android:
   Java JDK: installed 1.8.0
   Android SDK: installed true
   Android target: installed android-29
   Gradle: installed C:\Users\norman\development\gradle\gradle-6.5.1\bin\gradle.BAT
   
   cordova platform ls
   Installed platforms:
     android 9.0.0
   
   cordova -v
   9.0.0 (cordova-lib@9.0.1)
   
   node -v
   v12.18.2
   ```
   
   I guess I should mention that I was using command prompt, not powershell. I'll try with powershell and post results in a few.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-android] AyatoKirishima commented on issue #1027: gradlew: 'sh' is not recognized as an internal or external command,

Posted by GitBox <gi...@apache.org>.
AyatoKirishima commented on issue #1027:
URL: https://github.com/apache/cordova-android/issues/1027#issuecomment-1041757676


   ![image](https://user-images.githubusercontent.com/42692272/154300411-3ab6e413-0c46-43d6-a593-82879bd9e18a.png)
   
   An android emulator has to be running ! 
   phew 6hours later it's working <3


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org