Closed shankari closed 4 years ago
I poked around this a little bit, and the Failed to fetch plugin ... via registry
error is from cordova-lib/src/plugman/fetch.js
So the real error is Could not determine package name from output
Could not determine package name from output
is from node_modules//cordova-fetch/index.js
Essentially, the code expects the npm install output to have a +
, but it doesn't. The output is just phonegap-plugin-contentsync@1.4.2 node_modules/phonegap-plugin-contentsync
with no +
, which is why this fails.
The npm install command is launched using superspawn.spawn
.
And now I come to the part that I don't understand. If I use -d
, I can see the arguments passed in to npm install
If I run the exact same command using superspawn using the node REPL, I get an output with the +
But if I add the same kind of output logging in fetch.js
, it returns the output without the +
e.g. if I change the code to
I get the following output
I can't figure out why superspawn
behaves differently in the REPL and in the script. Any thoughts?
Finally, -d
also gives us a clue as to why the registry install works (eventually). It uses plugman install
instead of npm install
Thanks for reporting this and for the detailed information and debugging. It's indeed strange that the npm output differs between manual invocations and those performed by cordova-fetch.
Just to be sure that this is still an issue in the current code base, could you please try if you can reproduce this issue when using cordova@nightly?
Ok, so I poked around this some more, and I know the reason behind the difference in superspawn
behavior.
After adding log statements to all instances of superspawn, it looks like this is difference is due to the differences in the versions of superspawn included in the project.
$ find node_modules -name \*superspawn.js
node_modules/cordova/node_modules/cordova-common/src/superspawn.js
node_modules/cordova-common/src/superspawn.js
node_modules/cordova-create/node_modules/cordova-common/src/superspawn.js
node_modules/cordova-fetch/node_modules/cordova-common/src/superspawn.js
node_modules/cordova-lib/node_modules/cordova-common/src/superspawn.js
node_modules/phonegap/node_modules/cordova-common/src/superspawn.js
node_modules/phonegap/node_modules/cordova-create/node_modules/cordova-common/src/superspawn.js
While using node directly, we use node_modules/cordova-common/src/superspawn.js
, while using plugin add
, we use node_modules/cordova-fetch/node_modules/cordova-common/src/superspawn.js
. The two versions are different, although I cannot see which of the differences lead to this difference in behavior.
so the two versions are different because the versions of cordova-common
are different.
$ find node_modules -name package.json | grep "cordova-common.package" | xargs grep version.:
node_modules/cordova/node_modules/cordova-common/package.json: "version": "3.2.1"
node_modules/cordova-common/package.json: "version": "4.0.2"
node_modules/cordova-create/node_modules/cordova-common/package.json: "version": "3.2.1"
node_modules/cordova-fetch/node_modules/cordova-common/package.json: "version": "3.2.1"
node_modules/cordova-lib/node_modules/cordova-common/package.json: "version": "3.2.1"
node_modules/phonegap/node_modules/cordova-common/package.json: "version": "2.1.1"
node_modules/phonegap/node_modules/cordova-create/node_modules/cordova-common/package.json: "version": "2.2.5"
But if I use the cordova-fetch
version superspawn
directly in the REPL, it works correctly. Which is consistent with the diffs seeming fairly innocuous. The main difference seems to be running this in cordova.
I will try with the latest cordova@nightly and if that still doesn't work, I'm going to try to create a MCVE to make it easier for others to debug as well.
@raphinesse Confirmed that this occurs even with cordova@nightly
Aha! While creating the MCVE, figured out the issue. I have both cordova and phonegap as dependencies. I was working on upgrading cordova first, and had not yet started upgrading phonegap, which was still at 7.1.1
. After upgrading phonegap to 9.0.0+cordova.9.0.0
, the error disappeared. I guess 7.1.1
was close enough to 8.0.0
to work, but was too far from 9.0.0
Bug Report
Problem
What is expected to happen?
should succeed since "url to a git repository containing a plugin.xml" is a valid plugin-spec.
What does actually happen?
Information
on cordova@8.0.0, plugins can be added using either the registry or a git URL
In the same directory, with cordova@9.0.0, plugins can only be added using the registry, and only intermittently
Note that, in the case of the registry add, the first run of the command fails, and the second run of the identical command succeeds
However, the git add always fails.
Command or Code
OR
Environment, Platform, Device
Mac OSX Catalina 10.15.5
Version information
For cordova and ionic:
For other cordova dependencies, I have attached my package.json package.json.gz
For the rest of the environment:
Checklist