Skip to content

TNS doctor does not detect if JDK is not installed and throws an error #1922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vchimev opened this issue Jul 13, 2016 · 4 comments
Closed
Assignees
Labels
Milestone

Comments

@vchimev
Copy link

vchimev commented Jul 13, 2016

NativeScript CLI: 2.1.1
OS: OS X El Capitan

Actual

If no JDK and JAVA_HOME environment variable are available, tns doctor throws an error: Cannot read property``match``of null.

After that, a java prompt leading to www.java.com/en/download/mac_download.jsp appears (see #1863 (comment)) which provides a download of JRE, but not JDK required by NativeScript.

Expected

A clear warning that JDK is not installed or is not configured properly, similarly to Android SDK for example: WARNING: The Android SDK is not installed or is not configured properly.

Output of tns doctor --log trace:

TypeError: Cannot read property 'match' of null
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:566:15)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/common/errors.js:123:33
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/common/services/commands-service.js:84:106
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/common/dispatchers.js:38:85
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/nativescript-cli.js:22:45
    - - - - -
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/common/services/xcode-select-service.js:34:98
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/services/xcproj-service.js:35:138
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/services/xcproj-service.js:17:52
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/services/doctor-service.js:81:62
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/common/commands/doctor.js:17:72
    at Function.settle (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:249:26)
    at FiberFuture.Future.wait (/Users/nsbuilduser/Work/node_modules/nativescript/node_modules/fibers/future.js:565:10)
    at /Users/nsbuilduser/Work/node_modules/nativescript/lib/common/services/commands-service.js:51:55
Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }
Trying to track feature 'CLI' with value 'help'.
List of registered commands: /?, appstore, appstore|upload, autocomplete, autocomplete|disable, autocomplete|enable, autocomplete|status, build, build|android, build|ios, create, debug, debug|android, debug|ios, deploy, dev-generate-help, dev-generate-messages, dev-post-install, dev-preuninstall, dev-test, dev-test|android, dev-test|ios, device, device|android, device|get-file, device|ios, device|list-applications, device|list-files, device|log, device|put-file, device|run, device|stop, device|uninstall, doctor, emulate, emulate|android, emulate|ios, error-reporting, help, info, init, install, livesync, platform, platform|add, platform|clean, platform|remove, platform|update, plugin, plugin|add, plugin|find, plugin|remove, plugin|search, prepare, publish, publish|ios, run, run|android, run|ios, test, test|android, test|init, test|ios, usage-reporting
Reading help for command 'doctor'. FileName is 'doctor.md'.
# doctor
┌─────────┬──────────────┐
│ Usage   │ Synopsis     │
│ General │ $ tns doctor │
└─────────┴──────────────┘

Checks your system for configuration problems which might prevent the NativeScript CLI from working properly.

Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }
Trying to track exception with message 'Cannot read property 'match' of null'.

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Dec 9, 2016

Behavior in master 2.5, offers to install jdk and can't reproduce the aforementioned error: TypeError: Cannot read property 'match' of null. Tried reproducing on Yosemite and ElCapitan.
@vchimev can you try reproducing it again with cli from master.

@pkoleva
Copy link
Contributor

pkoleva commented Dec 22, 2016

Reproduced with the latest master of v 2.5.0. On mac the popup leads nowhere, on windows there is no popup, idk if there should be one.

@vchimev
Copy link
Author

vchimev commented Jan 4, 2017

A quick update from my side, as I got the chance to try this case on a clean Windows 10 machine.
On Windows 10 the expected behavior is met and there is a clear message that JKD is not installed.

Output:

C:\Users\vchimev\Work>node -v
v6.9.3

C:\Users\vchimev\Work>npm -v
3.10.10

C:\Users\vchimev\Work>tns --version
2.4.2

C:\Users\vchimev\Work>tns doctor
The ANDROID_HOME environment variable is not set or it points to a non-existent directory. You will not be able to perform any build-related operations for Android.
To be able to perform Android build-related operations, set the ANDROID_HOME variable to point to the root of your Android SDK installation directory.

...
...
...

Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable.
You will not be able to build your projects for Android.
To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as
 described in https://github.com/NativeScript/nativescript-cli#system-requirements.

screen shot 2017-01-04 at 1 35 36 pm

Only the hyperlink is no more relevant.

I would give again a try on macOS when get the chance.

@pkoleva pkoleva closed this as completed Jan 5, 2017
@Plamen5kov
Copy link
Contributor

Plamen5kov commented Jan 5, 2017

The initial error: Cannot read property``match``of null. happens because cli can't find a system command which should be in path by default. The searched command is xcodebuild.
The problem is fixed when the user fixes the PATH to include /usr/bin folder, which is there by default.
If this folder is missing, it's probably because the user had done something to change the default configuration of the PATH variable, or has removed the whole /usr/bin/ folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants