Error Adding Cordova Plugin From Git Repo


#1

In trying to upgrade my project to Meteor 1.2 on mobile i’ve run into an issue converting the plugin repo urls over.

To add a cordova plugin from a git repo Meteor documentation says:

meteor add cordova:com.phonegap.plugins.facebookconnect@https://github.com/Wizcorp/phonegap-facebook-plugin.git#5dbb1583168558b4447a13235283803151cb04ec

So I tried that with a plugin I was currently using before Meteor 1.2 which is here: https://github.com/xmartlabs/cordova-plugin-market. Which adding it should give me:

meteor add cordova:com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market.git#4421fffe9d3feba07c081dfd6c20c815ba81deb9

However when I build for android / ios I get an error that it couldn’t be found or the plugin spec is incorrect. The weird thing is when I go back and look at the plugin added via meteor list I see:

cordova:com.xmartlabs.cordova.market https://github.com/xmartlabs/cordova-plugin-market.git (Without the prepending slash which indicated which commit to checkout).

And indeed if I go back to look at how cordova-update was built, which comes from a git repo, meteors console looks like:

Adding plugin https://github.com/meteor/com.meteor.cordova-update.git#16c53f53e438fc8b1b9c768de36f0a8974e38b49 to Cordova project
% Fetching plugin “https://github.com/meteor/com.meteor.cordova-update.git” via git clone
% Repository “https://github.com/meteor/com.meteor.cordova-update.git” checked out to git ref “16c53f53e438fc8b1b9c768de36f0a8974e38b49”.

While the error’d plugin looks like:

Adding plugin com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market.git to Cordova project
% Fetching plugin “com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market.git” via npm
npm ERR! addLocal Could not install /var/folders/tb/gj5sy97j7pg4bvmwnmjgtb_w0000gn/T/npm-58241-5b415895/git-cache-1f2262f3ade3/4421fffe9d3feba07c081dfd6c20c815ba81deb9
% Fetching plugin “com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market.git” via cordova plugins registry
npm ERR! addLocal Could not install /var/folders/tb/gj5sy97j7pg4bvmwnmjgtb_w0000gn/T/npm-58241-5b415895/git-cache-e6bfe0ada6c4/4421fffe9d3feba07c081dfd6c20c815ba81deb9
=> Errors executing Cordova commands:

While adding plugin com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market.git to Cordova project:
Cordova error: CordovaError: Failed to fetch plugin com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market.git via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: EISDIR, read

Notice it didnt try and fetch the specific commit. What gives.


#2

Hmmm, confirmed this is a bug. Unfortunately, directly adding a Cordova plugin (meteor add) with a Git URL doesn’t work because the part after # will be removed when reading cordova-plugins. As this bug does not affect plugin dependencies in packages specified using Cordova.depends, a workaround is to create a local package.

A fix should be in the next point release.


#3

@martijnwalraven

Yep you are correct. Cordova.depends works that way just fine. I actually found a work around to this for the command line. I noticed that Meteor automatically tried to convert all my cordova git urls to the new format. If you go back and remove the offending plugins with the bad git urls and then re-add them with the old style git urls they still work.

For instance

meteor add cordova:com.xmartlabs.cordova.market@https://github.com/xmartlabs/cordova-plugin-market/tarball/4421fffe9d3feba07c081dfd6c20c815ba81deb9

Still works for now.


#4

As of version 1.2.0.1, the tarball URL no longer works. I’m seeing this error:

➜ 5:08PM ma-cordova git:(develop) ✗ meteor add cordova:com.xxx.qaps.mobile.plugin.phone@https://github.xxx.com/lsacco/cordova-phone/tarball/a6954116419107014165b7ae093b656203d9c0cf
Added Cordova plugin
com.xxx.qaps.mobile.plugin.phone@https://github.xxx.com/lsacco/cordova-phone/tarball/a6954116419107014165b7ae093b656203d9c0cf.
➜ 5:27PM ma-cordova git:(develop) ✗ meteor run ios
[[[[[ ~/dev/mobile-approvals/ma-cordova ]]]]]

=> Started proxy.
=> Started MongoDB.
=> Errors prevented startup:

While installing Cordova plugins:
error: Meteor no longer supports installing Cordova plugins from arbitrary tarball URLs. You can either add a
plugin from a Git URL with a SHA reference, or from a local path. (Attempting to install from
https://github.xxx.com/lsacco/cordova-phone/tarball/a6954116419107014165b7ae093b656203d9c0cf.)

=> Your application has errors. Waiting for file change.


#5

Ah yes, I forgot. I actually added them to the .meteor/cordova-plugins file directly. I didn’t go through meteor add [plugin].


#6

I was able to add them using meteor add.

First, I cloned the git project under myapp/private folder. It’s important it’s private otherwise Meteor will pick-up the www/*.js files and try to compile like normal causing other issues (e.g., “module” or “require” is not defined).

Second, use the following command to add them to your project:

meteor add cordova:com.loutilities.qaps.mobile.plugin.phone@file://./private/plugins/cordova-plugin-phone

This will them to the cordova-plugins directory along with the other bits they add.


#7

Thanks! I was having the same problem and this seemed to do the trick to get it to run at least (doesn’t work for me yet, but that’s up next).


#8

@martijnwalraven cool. Is there an early release we could test this with?


#9

This should be fixed in the current release, Meteor 1.2.0.2.


#10

@martijnwalraven thanks. I am running 1.2.0.2


#11

So do you mean you still have issues with this?


#12

Yes. The error I mentioned before.

Adam Ginsburg
adam.ginsburg@buzzy.buzz
tel: +61 411 151 732
http://buzzy.buzz


#13

Could you elaborate on this? What error specifically do you encounter with 1.2.0.2, and what seems to trigger it?


#14

@martijnwalraven oops, was answering via email… too many threads :wink: please see this for details: https://github.com/raix/push/issues/120


#15

Ok, I responded on the linked issue.