Missing git leads to not obvious error message on `platform add`
- Dominant language
- JavaScript
- Stars
- 967
- Forks
- 344
- Avg merge
- 8h 41m
- Merged PRs (30d)
- 9
Description
# Bug Report
## Problem
For complicated reasons [1] I am trying to run `cordova platform add https://github.com/apache/cordova-windows` in a temporarily elevated prompt. The way my system is set up, `git` is only installed on my user account, but not for Admin.
This caused this non obvious (to me) error message:
```
PS E:\Projects\throwaway\cordovaAdminWindowsNpmFail> cordova platform add https://github.com/apache/cordova-windows
Using cordova-fetch for https://github.com/apache/cordova-windows
Failed to fetch platform https://github.com/apache/cordova-windows
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/apache/cordova-windows.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2019-07-03T11_36_43_837Z-debug.log
```
After installing `git` for the Admin user, this problem is gone.
Maybe we can give better error messages here?
## Checklist
- [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
[1] I am trying to get Paramedic CI to work for cordova-windows. As AppVeyor, the CI we use runs in admin mode, I have to remove an exception from cordova-windows that is thrown if run in an admin prompt. To test this, I am trying to run paramedic's Windows tests locally, which works for non-admin prompts, but not admin ones. To understand I am trying to run the commands manually, but encountered this problem.
Contributor guide
Research direction
Start at the `cordova platform add` entry point and reproduce the command in an elevated prompt where `git` is unavailable. Trace the fetch failure and make the resulting message identify the missing Git executable and how it affects fetching the platform URL; verify the command no longer reports only a generic connection or platform-spec error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, javascript, node.js
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100