NativeScript / NativeScript/nativescript-cli

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

未關閉
#5,819 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug-pending-triage
主要語言
JavaScript
星號
1.1k
分支
204
平均合併
1 天 9 小時
30 天內合併 PR
8

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先追蹤 ns doctor androidns run android 使用的 NativeScript CLI 進入點,著重了解它們如何尋找並呼叫 adbemulator。使用上方所述的 Windows Android SDK 設定在 WSL2 中重現此錯誤。當兩個命令都能辨識 Windows 可執行檔名稱而不需要 symlink 時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
android, javascript
領域
cli, mobile
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。