[ https://issues.apache.org/jira/browse/CB-13637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16283763#comment-16283763 ]
Michael Goffioul commented on CB-13637: --------------------------------------- After some digging, it appears that although npm can handle relative "file:" URLs, plugman cannot. The problem seems to start around this location: https://github.com/apache/cordova-lib/blob/master/src/plugman/fetch.js#L115 The variable "plugin_src" contains a relative file URL, like "file:localplugins/testplugin". But the use of that URL in node's fs module fails, for instance to code fails to detect that it's a local path and handle it accordingly. I could verify that adding this code just above referenced line fix the problem for me: {code} if (uri.protocol === 'file:' && uri.pathname && uri.pathname[0] !== '/') { plugin_src = plugin_src.substring(5); } {code} > Unable to handle local plugins properly > --------------------------------------- > > Key: CB-13637 > URL: https://issues.apache.org/jira/browse/CB-13637 > Project: Apache Cordova > Issue Type: Bug > Components: cordova-lib > Reporter: Michael Goffioul > > 1) create a new cordova project > 2) inside the project directory, create folder "localplugins/testplugin" > containing the file: > - package.json > {code} > { > "name": "com.example.cordova.plugin", > "version": "1.0.0" > } > {code} > - plugin.xml > {code} > <?xml version="1.0" encoding="UTF-8"?> > <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" > id="com.example.cordova.plugin" version="1.0.0"> > <name>Test Plugin</name> > <platform name="android"> > <config-file target="AndroidManifest.xml" parent="/*"> > <uses-permission android:name="android.permission.WAKE_LOCK" /> > </config-file> > </platform> > </plugin> > {code} > 3) add android patform: cordova platform add android > 4) prepare android: cordova prepare android > At this point, both package.json and config.xml contain a reference to the > plugin using "file:localplugins/testplugin". The problem is that it's > impossible to use the same plugin reference in both files, and still having > plugin restoration and/or "npm install" to work. > If I delete platforms/ and plugins/ subdir (these are typically not under git > revision control) and run "cordova prepare android" to restore the platforms > and the plugins, it fails with error: > {code} > Discovered plugin "com.example.cordova.plugin" in config.xml. Adding it to > the project > Failed to restore plugin "com.example.cordova.plugin" from config.xml. You > might need to try adding it again. Error: Failed to fetch plugin > file:localplugins/testplugin via registry. > Probably this is either a connection problem, or plugin spec is incorrect. > Check your connection and plugin name/version/URL. > Failed to get absolute path to installed module > {code} > If I edit package.json and config.xml, and remove the prefix "file:" in the > plugin spec, then restoration works ok. But then, it's "npm install" that > fails. > What works is to use the "file:" prefix in package.json and not use it in > "config.xml". But that's not possible as preparation will make sure both are > identical. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org