Cannot add plugin to a Cordova project in a subdirectory of the plugin
- Dominant language
- JavaScript
- Stars
- 967
- Forks
- 344
- Avg merge
- 8h 41m
- Merged PRs (30d)
- 9
Description
# Bug Report
## Problem
### What is expected to happen?
Some plugins may include an example app project (demonstrating the plugin functionality) in a subdirectory of their repository. It should be possible to add the plugin to such an example app project using a local path.
```sh
|--- myPlugin/
| |--- exampleApp/ (uses myPlugin)
$ cd exampleApp
$ cordova plugin add ..
```
### What does actually happen?
When adding a plugin to a Cordova project located in a subdirectory of the plugin to be installed, Cordova CLI exits with an error.
## Information
This issue might be related to the fact that `npm install` creates symlinks when installing a local package. Cordova may attempt to copy the symlink to the plugin to a subdirectory of the plugin (using [ShellJS](https://github.com/shelljs/shelljs)), resulting in endless recursion.
### Command or Code
```sh
$ plugman create --name myPlugin --plugin_id my.plugin.id --plugin_version 0.1.0
$ cd myPlugin
$ plugman createpackagejson .
# ... confirm interactive prompt ...
$ mkdir exampleApp
$ cd exampleApp
$ cordova create .
$ cordova plugin add ..
shell.js: internal error
Error: ENAMETOOLONG: name too long, lstat '/private/tmp/myPlugin/exampleApp/node_modules/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp/plugins/my.plugin.id/exampleApp'
at Object.fs.lstatSync (fs.js:965:11)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:69:26)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
at cpdirSyncRecursive (/Users/cpetrov/.nvm/versions/node/v9.7.1/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/shelljs/src/cp.js:73:7)
```
### Version information
macOS 10.14
Cordova CLI 8.1.2 (cordova-lib@8.1.1)
npm 6.4.1
Node.js v9.7.1
Plugman 2.0.0
## 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
Research direction
Reproduce the local-plugin install from the issue using the Cordova CLI, Plugman, npm, and the nested exampleApp layout. Start with the ShellJS cp.js stack-trace entry point and trace how the local package and symlink are copied; done means `cordova plugin add ..` completes without recursive paths or ENAMETOOLONG.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- cli, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100