Can't install Cordova plugins from Git on CLI
Asked Answered
K

4

39

I have been racking my brain on this for a while now. I am developing an Android app on Windows 7 in Cordova 3.4 and I can't get any of the non-core plugins to install (like Google Analytics, Social Share). I know that I have plugman, node, git, cordova, and the CLI installed because when I type them into a command prompt I get back a valid response. The Android SDK is working, and I have updated all of these modules and tried re-installing. Here is the error I receive when I try to install a plugin that is not part of Cordova core:

C:\Users\UserName\Desktop\hello>cordova plugin add https://github.com/danwilson/google-analytics-plugin.git
Fetching plugin "https://github.com/danwilson/google-analytics-plugin.git" via git clone
Error: Command failed: fatal: could not create work tree dir 'C:\Users\DAVIDH~1\AppData\Local\Temp\plugman\git\1397683376354'.: No such file or directory

I'm wondering if this is a PATH issue or not, though I have tried many solutions related to this. Your advice and guidance is greatly appreciated. Thanks!

Katzir answered 16/4, 2014 at 22:34 Comment(0)
I
94

It seems there is a bug in git source dependencies on Windows.

Try to create the directory manually :

mkdir C:\Users\DAVIDH~1\AppData\Local\Temp\plugman\git

Then :

git clone https://github.com/danwilson/google-analytics-plugin.git

From there : https://github.com/sbt/sbt/issues/895

EDIT

I removed the numerical extension, which is not needed, to follow the remark from FugueWeb

UPDATE (From Sept 2014)

As noted in Daren Beale's answer and also in the issue linked above, this bug is fixed in Git 1.9.4. Downloading the latest version of GIT for Windows should get around this problem.

Izaguirre answered 16/4, 2014 at 22:54 Comment(3)
Thanks slaadvak, this did the trick. However, I didn't need to add the numeric extension to \git, since I noticed that it changed every time I attempted to install the plugin (even for the same plugin).Katzir
@Katzir Thanks for the comment, not adding the numeric extension to \git got the job done :)Sparoid
I didn't need to explicitly run git clone after creating the directory. I created the directory and then re-ran the Cordova plugin add command and it successfully pulled in the plugin.Lashoh
D
7

I had this exact issue on my desktop but not on my laptop, as suggested above it look like a Git issue. Installing the latest version of Git on my desktop (1.9.4) fixed the problem.

Doody answered 19/6, 2014 at 8:46 Comment(2)
Verified. You can work around it in the ways mentioned above, but the next version of git will just make the needed directories for you. Using git 1.9.4 fixes this.Spenser
This worked for me! To update git: chocolatey update git (chocolatey.org is a package manager for windows)Orton
D
2

I was experiencing a similar issue while issuing the commands from cygwin, cygwin's temp folder structure is a bit different

Manually creating the parent folders (plugman and git), which doesn't exist, fixes the issue (the numbered folders can be created under the plugman/git folders later on)

Dodgem answered 25/5, 2014 at 22:30 Comment(0)
V
0

On my machine the issue was, that git wasn't available in the cmd in windows. Open cmd and type "git" and press enter. If there is shown, that the command is not available, then you might have the same issue.

Solution:

Find out where your git.exe is located. For me it was a custom path in "D:\Program Files\Git\bin". Then search in windows for "environment variables" and open the link to the shown windows settings.

Find the entry "Path" and click on "edit". Add the path to the git.exe file (without "git.exe"). Restart cmd and type "git".

If that was the only issue the installation of cordova plugins over git should work.

Vann answered 26/1, 2018 at 13:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.