apache / apache/cordova-cli

'cordova plugin add' with searchpath doesn't work

Open
#455 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
967
Forks
344
Avg merge
8h 41m
Merged PRs (30d)
9

Description

# Bug Report

## Problem
`cordova plugin add` with searchpath doesn't work. CLI will prompt error code 404 not found.

### Command or Code
Suppose I have a locally built cordova plugin kapsel-plugin-corelibs@4.2.7-SNAPSHOT in folder C:\SAP\KapselSDK4.2.7snapshot\plugins.

Run the command `cordova plugin add kapsel-plugin-corelibs --searchpath C:\SAP\KapselSDK4.2.7snapshot\plugins --verbose`
then following error occurs:
```
No scripts found for hook "before_plugin_add".
No version specified for kapsel-plugin-corelibs, retrieving version from config.xml
No version for kapsel-plugin-corelibs saved in config.xml or package.json
Not checking npm info for kapsel-plugin-corelibs because searchpath or noregistry flag was given
Calling plugman.fetch on plugin "kapsel-plugin-corelibs"
fetch: Installing kapsel-plugin-corelibs to C:\Users\i062893\cordova-workspace\app
Running command: npm install kapsel-plugin-corelibs --production --save
Command finished with error code 1: npm install,kapsel-plugin-corelibs,--production,--save
Failed to fetch plugin kapsel-plugin-corelibs via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/kapsel-plugin-corelibs - Not found
npm ERR! 404
npm ERR! 404 'kapsel-plugin-corelibs@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\i062893\AppData\Roaming\npm-cache\_logs\2019-09-02T06_17_19_544Z-debug.log
CordovaError: Failed to fetch plugin kapsel-plugin-corelibs via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: npm: Command failed with exit code 1 Error output:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/kapsel-plugin-corelibs - Not found
npm ERR! 404
npm ERR! 404 'kapsel-plugin-corelibs@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\i062893\AppData\Roaming\npm-cache\_logs\2019-09-02T06_17_19_544Z-debug.log
at C:\Users\i062893\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\fetch.js:146:43
at process._tickCallback (internal/process/next_tick.js:68:7)
```

Please note that the workaround is to append version in the plugin name: so if I run command `cordova plugin add kapsel-plugin-corelibs@4.2.7-SNAPSHOT --searchpath C:\SAP\KapselSDK4.2.7snapshot\plugins --verbose`
The plugin can be added successfully:
```
No scripts found for hook "before_plugin_add".
Calling plugman.fetch on plugin "kapsel-plugin-corelibs@4.2.7-SNAPSHOT"
Found kapsel-plugin-corelibs@4.2.7-SNAPSHOT at C:\SAP\KapselSDK4.2.7snapshot\plugins\corelibs
Copying plugin "C:\SAP\KapselSDK4.2.7snapshot\plugins\corelibs" => "C:\Users\i062893\cordova-workspace\app\plugins\kapsel-plugin-corelibs"
Adding kapsel-plugin-corelibs to package.json
No scripts found for hook "after_plugin_add".
```

### Environment, Platform, Device

Windows 10.

### Version information

Cordova CLI version: 9.0.0 (cordova-lib@9.0.1)

## 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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Windows command with a local plugin and --searchpath, then inspect cordova-lib/src/plugman/fetch.js around line 146 and the plugman.fetch entry point. Done means a plugin without an explicit version is found in the search path and installed locally without falling back to npm or producing a 404.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.