NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 195 forks source link

`doctor` and `run` fail on WSL2 with Android SDK installed on Windows #5819

Open dszymon opened 3 weeks ago

dszymon commented 3 weeks ago

Issue Description

NativeScript CLI wrongly assumes adb and emulator as executable names instead of adb.exe and emulator.exe

As a workaround, you can create a symlink named adb and emulator pointing to their equivalents with the .exe extension

Reproduction

  1. install Android SDK on Windows to C:\android\sdk
  2. setup WSL2 with NativeScript CLI
  3. set ANDROID_HOME to C:\android\sdk, ANDROID_SDK_ROOT to $ANDROID_HOME and add $ANDROID_HOME/platform-tools to $PATH
  4. run ns run android --device <device id> or ns doctor android
  5. the command fails because it tests adb and emulator instead of adb.exe and emulator.exe

Relevant log output (if applicable)

ns --log trace run android --device emulator-5554

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
                        *
*  The "TRACE" log level might print some sensitive data like secrets or access tokens in request URLs. Be careful when you share this output.  *
*
                        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Looking for project in '/home/szymek/projects/nativescriptjazda/tamagoczi'
Project directory is '/home/szymek/projects/nativescriptjazda/tamagoczi'.
Initializing project identifiers. Config:  {
  id: 'org.nativescript.tamagoczi',
  appPath: 'src',
  appResourcesPath: 'App_Resources',
  android: { v8Flags: '--expose_gc', markingMode: 'none' },
  cli: { packageManager: 'bun' }
}
Loading extensions.
Collecting system information...
System information:
{
  "platform": "linux",
  "shell": "/bin/bash",
  "os": "Linux DESKTOP-RJEK15K 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux\n",
  "procArch": "x64",
  "nodeVer": "21.7.3",
  "npmVer": "10.5.0",
  "nodeGypVer": "10.2.0",
  "nativeScriptCliVersion": "8.8.2",
  "gitVer": "2.25.1",
  "dotNetVer": null,
  "javacVersion": "17.0.12",
  "javaVersion": "17.0.12",
  "javaPath": "java",
  "adbVer": null,
  "androidInstalled": true,
  "monoVer": null,
  "gradleVer": null,
  "isAndroidSdkConfiguredCorrectly": false,
  "xcodeprojLocation": null,
  "itunesInstalled": false,
  "isCocoaPodsWorkingCorrectly": false,
  "isCocoaPodsUpdateRequired": false,
  "pythonInfo": null
}
Current CLI version:  8.8.2
Project dir from hooksArgs is: undefined.
Hooks directories: [ '/home/szymek/projects/nativescriptjazda/tamagoczi/hooks' ]
BeforeHookName for command resolveCommand is before-resolveCommand
Project dir from hooksArgs is: undefined.
AfterHookName for command resolveCommand is after-resolveCommand
Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.
The stackTrace of the location trying to handle SIGINT is (note: this is not an error, just a stack-trace for debugging purposes):
    at process.on (/home/szymek/.bun/install/global/node_modules/nativescript/lib/nativescript-cli.js:28:28)
    at Object.<anonymous> (/home/szymek/.bun/install/global/node_modules/@ionic/utils-process/dist/index.js:145:13)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/home/szymek/.bun/install/global/node_modules/@ionic/utils-subprocess/dist/index.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
Migration cache path is: /home/szymek/.local/share/.nativescript-cli/should-migrate-cache-8.8.2.json
Trying to handle SIGINT event. CLI overrides this behavior and does not allow handling SIGINT as this causes issues with Ctrl + C in terminal.
The stackTrace of the location trying to handle SIGINT is (note: this is not an error, just a stack-trace for debugging purposes):
    at process.on (/home/szymek/.bun/install/global/node_modules/nativescript/lib/nativescript-cli.js:28:28)
    at /home/szymek/.bun/install/global/node_modules/signal-exit/index.js:158:17
    at Array.filter (<anonymous>)
    at load (/home/szymek/.bun/install/global/node_modules/signal-exit/index.js:156:23)
    at module.exports (/home/szymek/.bun/install/global/node_modules/signal-exit/index.js:62:7)
    at Object.<anonymous> (/home/szymek/.bun/install/global/node_modules/proper-lockfile/lib/lockfile.js:331:1)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
spawn: /usr/bin/node "/home/szymek/.bun/install/global/node_modules/nativescript/lib/detached-processes/cleanup-process.js" "/home/szymek/.bun/install/global/node_modules/nativescript/lib/bootstrap.js"
(node:19089) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Shasum of file /home/szymek/projects/nativescriptjazda/tamagoczi/package.json is 837e859413535462915b4d431c11718ac308fcf3
Got cached result for shouldMigrate for platform: Android: false
Project dir from hooksArgs is: /home/szymek/projects/nativescriptjazda/tamagoczi.
BeforeHookName for command checkEnvironment is before-checkEnvironment
Initializing analytics statuses.
Analytics statuses:  { TrackFeatureUsage: 'enabled', TrackExceptions: 'enabled' }
Will send the following information to Google Analytics: {
  type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'event',
  action: 'Check Local Build Setup',
  label: 'Starting',
  customDimensions: { cd2: 'Vue.js', cd9: 'false', cd5: 'CLI' },
  value: undefined
}
spawn: /usr/bin/node "/home/szymek/.bun/install/global/node_modules/nativescript/lib/services/analytics/analytics-broker-process.js" "/home/szymek/.bun/install/global/node_modules/nativescript/lib/bootstrap.js"
Error while trying to parseJson  data from /home/szymek/.local/share/.nativescript-cli/doctor-cache.json file. Err is: SyntaxError: Unexpected end of JSON input
getInfos cacheConfig options: { forceCheck: undefined }  current info from cache:  null
Will send the following information to Google Analytics: {
  type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'event',
  action: 'Check Local Build Setup',
  label: 'Warnings:WARNING: adb from the Android SDK is not installed or is not configured properly. __WARNING: The Android SDK is not installed or is not configured properly.',
  customDimensions: { cd2: 'Vue.js', cd9: 'false', cd5: 'CLI' },
  value: undefined
}
✔ Your ANDROID_HOME environment variable is set and points to correct directory.
✔ A compatible Android SDK for compilation is found.
✔ Javac is installed and is configured properly.
✔ The Java Development Kit (JDK) is installed and is configured properly.
✔ Local builds for iOS can be executed only on a macOS system. To build for iOS on a different operating system, you can use the NativeScript cloud infrastructure.
✖ WARNING: adb from the Android SDK is not installed or is not configured properly.
 For Android-related operations, the NativeScript CLI will use a built-in version of adb.
To avoid possible issues with the native Android emulator, Genymotion or connected
Android devices, verify that you have installed the latest Android SDK and
its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

✖ WARNING: The Android SDK is not installed or is not configured properly.
 You will not be able to run your apps in the native emulator. To be able to run apps
in the native Android emulator, verify that you have installed the latest Android SDK
and its dependencies as described in http://developer.android.com/sdk/index.html#Requirements

Will send the following information to Google Analytics: {
  type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'event',
  action: 'Check Local Build Setup',
  label: 'Finished: Is setup correct: false',
  customDimensions: { cd2: 'Vue.js', cd9: 'false', cd5: 'CLI' },
  value: undefined
}
Will send the following information to Google Analytics: {
  type: 'googleAnalyticsData',
  category: 'CLI',
  googleAnalyticsDataType: 'event',
  action: 'Check Environment Requirements',
  label: 'Non-interactive terminal, unable to execute local builds.',
  customDimensions: { cd2: 'Vue.js', cd9: 'false', cd5: 'CLI' },
  value: undefined
}
Your environment is not configured properly and you will not be able to execute local builds.
Verify that your environment is configured according to the system requirements described at
https://docs.nativescript.org/setup/linux#setting-up-linux-for-android.
Error: Your environment is not configured properly and you will not be able to execute local builds.
Verify that your environment is configured according to the system requirements described at
https://docs.nativescript.org/setup/linux#setting-up-linux-for-android.
    at Errors.failWithOptions (/home/szymek/.bun/install/global/node_modules/nativescript/lib/common/errors.js:165:27)
    at Errors.fail (/home/szymek/.bun/install/global/node_modules/nativescript/lib/common/errors.js:137:21)
    at PlatformEnvironmentRequirements.fail (/home/szymek/.bun/install/global/node_modules/nativescript/lib/services/platform-environment-requirements.js:66:22)
    at PlatformEnvironmentRequirements.<anonymous> (/home/szymek/.bun/install/global/node_modules/nativescript/lib/services/platform-environment-requirements.js:57:22)
    at Generator.next (<anonymous>)
    at fulfilled (/home/szymek/.bun/install/global/node_modules/nativescript/lib/services/platform-environment-requirements.js:11:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Environment

OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Shell: /bin/bash
node: 21.7.3
npm: 10.5.0
nativescript: Not Found

# android
java: 17.0.12
ndk: Not Found
apis: Not Found
build_tools: Not Found
system_images: Not Found

# ios
xcode: Not Found
cocoapods: Not Found
python: Not Found
python3: 3.8.10
ruby: Not Found
platforms: Not Found

Dependencies

"dependencies": {
  "@nativescript/core": "~8.7.0",
  "nativescript-vue": "3.0.0-rc.2"
},
"devDependencies": {
  "@nativescript-dom/core-types": "1.0.31",
  "@nativescript-dom/vue-types": "1.0.16",
  "@nativescript/android": "^8.8.6",
  "@nativescript/preview-cli": "^1.0.13",
  "@nativescript/types": "~8.7.0",
  "@nativescript/webpack": "~5.0.0",
  "@types/node": "~17.0.21",
  "typescript": "^5.4.5",
  "vue-tsc": "2.1.10"
}

Please accept these terms