Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335959 - Cloning GIT repository fails because it couldn't delete file index.lock
Summary: Cloning GIT repository fails because it couldn't delete file index.lock
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 minor with 4 votes (vote)
Target Milestone: 0.12   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-01 09:24 EST by Bojan Siljanovski CLA
Modified: 2013-01-12 05:01 EST (History)
8 users (show)

See Also:


Attachments
Eclipse Error Log (631.88 KB, application/octet-stream)
2011-07-26 19:01 EDT, mterber CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bojan Siljanovski CLA 2011-02-01 09:24:41 EST
Build Identifier: 20100917-0705

I got the following message.

Could not delete file C:\Development\projects\test\.git\index.lock
Could not delete file C:\Development\projects\test\.git\index.lock

This causes cloning to fail.  However, once I pause Kaspersky Antivirus, I don't have this problem.  

Reproducible: Always

Steps to Reproduce:
1.Make sure Kaspersky antivirus is running.
2.Clone git repository.
3.Error will occur during cloning.
Comment 1 Chris Aniszczyk CLA 2011-02-01 09:39:54 EST
Can you try with the latest nightly build?

Also, can you give us a stacktrace?
Comment 2 Gordon Vidaver CLA 2011-05-05 14:16:06 EDT
This failed for me too, when creating from a bundle.  I don't have Kaspersky but McAfee.

I'd put this under "major" since I can't create a project from a bundle.
Comment 3 Chris Aniszczyk CLA 2011-05-05 14:18:07 EDT
Which version of EGit/JGit?

Can you post a stacktrace?
Comment 4 Gordon Vidaver CLA 2011-05-05 14:59:43 EDT
EGit 0.11.1

!MESSAGE Git repository clone failed.
!STACK 0
java.io.IOException: Could not delete file C:\Users\go22670\mt_repo\goodwave\gw\gw_bundle\.git\index.lock
	at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:134)
	at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
	at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
	at org.eclipse.egit.core.op.CloneOperation.run(CloneOperation.java:142)
	at org.eclipse.egit.ui.internal.clone.GitCloneWizard.executeCloneOperation(GitCloneWizard.java:259)
	at org.eclipse.egit.ui.internal.clone.GitCloneWizard.access$3(GitCloneWizard.java:252)
	at org.eclipse.egit.ui.internal.clone.GitCloneWizard$3.run(GitCloneWizard.java:216)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 5 Chris Aniszczyk CLA 2011-05-05 15:15:57 EDT
Can you try with the latest version of EGit, 0.12?

http://download.eclipse.org/egit/updates-0.12
Comment 6 Gordon Vidaver CLA 2011-05-05 16:10:34 EDT
After updating to egit 0.12.1

eclipse.buildId=M20110210-1200
java.version=1.6.0_21
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product


Error
Thu May 05 16:07:30 EDT 2011
Git repository clone failed.

java.io.IOException: Could not delete file C:\Users\go22670\mt_repo\goodwave\gw\gw_bundle_3\goodwave.bundle\.git\index.lock
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:134)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
at org.eclipse.egit.core.op.CloneOperation.run(CloneOperation.java:150)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard.executeCloneOperation(GitCloneWizard.java:291)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard.access$3(GitCloneWizard.java:284)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard$4.run(GitCloneWizard.java:248)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 7 Chris Aniszczyk CLA 2011-05-05 16:21:14 EDT
Any thoughts on this Matthias?
Comment 8 Stevo Slavic CLA 2011-06-06 15:37:02 EDT
I've been hit by this same unwanted behavior, when trying to clone JiBX repo ( git://jibx.git.sourceforge.net/gitroot/jibx/jibx ) cloning fails with [1].

I'm using egit 0.12.1, eclipse 3.6 SR2 (build 20110218-0911), Sun/Oracle JDK 1.6 update 25 x64, on both Windows 7 x64 and Windows Vista Business x64 SP1. On both systems there is different antivirus, and turning it of didn't help with this issue.

After cloning fails, if I try manually to delete jibx/.git/index.lock file, I can do it.

Regards,
Stevo.

[1] Jibx repo clone error
!ENTRY org.eclipse.egit.ui 4 0 2011-06-05 13:27:41.172
!MESSAGE Could not delete file C:\Users\s.slavic\jibx\.git\index.lock
!STACK 0
java.io.IOException: Could not delete file
C:\Users\s.slavic\jibx\.git\index.lock
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:134)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
at org.eclipse.egit.core.op.CloneOperation.run(CloneOperation.java:150)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard.executeCloneOperation(GitCloneWizard.java:291)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard.access$3(GitCloneWizard.java:284)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard$5.run(GitCloneWizard.java:265)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 9 Stevo Slavic CLA 2011-06-06 15:51:56 EDT
If I understand well, "run" method in CloneOperation will try to clean up working directory (clone destination I guess) after a failure is encountered (Exception gets thrown during cloning) (see http://egit.eclipse.org/w/?p=egit.git;a=blob;f=org.eclipse.egit.core/src/org/eclipse/egit/core/op/CloneOperation.java;h=c75bde69c9015ead9b3f436dbed1097902b89a4a;hb=HEAD ). Original error doesn't get logged before trying to delete working directory. Something else is actually preventing cloning to complete, and all we see is stacktrace from a different error following primary error.
Comment 10 Steffen.Brauss CLA 2011-07-12 06:18:55 EDT
Hello, 
got same Error Message with latest version (0.12.1)
Stacktrace is nearly the same on a Windows OS in EGit as from Gordon Vidaver 2011-05-05 14:59:43 EDT post.

Git on cygwin can clone the whole repository.

Problem might be the including the leading spaces. 
Example: 
...\src\ java sample \test\Test.java 
Leading spaces aren't best practise and make life more complicated because at least a Unix emulation like Cygwin is needed. Not all people are free to use a Unix style OS.

Stacktrace:
Folgende Fehlermeldung:
 eclipse.buildId=M20110210-1200
 java.version=1.6.0_07
 java.vendor=Sun Microsystems Inc.
 BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
 Framework arguments:  -product org.eclipse.epp.package.jee.product
 Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.jee.product -clean -data C:\projekte\copypaste351
 
 
 Error
 Tue Jul 12 10:38:49 CEST 2011
 Git repository clone failed.
 
 java.io.IOException: Could not delete file C:\develop\eclipse3.6.2_git\gitrepo\basis2\.git\index.lock
 at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:134)
 at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
 at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
 at org.eclipse.egit.core.op.CloneOperation.run(CloneOperation.java:151)
 at org.eclipse.egit.ui.internal.clone.GitCloneWizard.executeCloneOperation(GitCloneWizard.java:292)
 at org.eclipse.egit.ui.internal.clone.GitCloneWizard.access$3(GitCloneWizard.java:285)
 at org.eclipse.egit.ui.internal.clone.GitCloneWizard$4.run(GitCloneWizard.java:249)
 at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Comment 11 mterber CLA 2011-07-26 19:01:14 EDT
Created attachment 200407 [details]
Eclipse Error Log
Comment 12 Oliver Köhler CLA 2011-07-28 13:02:19 EDT
Hi, 
same behaviour to me.
Win7 64Bit.
No spaces in full-foldername.

java.io.IOException: Could not delete file C:\Users\Dev\repo.git\.git\index.lock
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:134)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
at org.eclipse.jgit.util.FileUtils.delete(FileUtils.java:119)
at org.eclipse.egit.core.op.CloneOperation.run(CloneOperation.java:142)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard.executeCloneOperation(GitCloneWizard.java:259)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard.access$3(GitCloneWizard.java:252)
at org.eclipse.egit.ui.internal.clone.GitCloneWizard$3.run(GitCloneWizard.java:216)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

Regards

Oliver
Comment 13 Matthias Sohn CLA 2011-08-02 07:10:20 EDT
could you try to identify the process holding a file lock which prevents egit to delete index.lock, refer to [1] which tools could be used for that.

[1] http://www.thefreecountry.com/utilities/deletelockedfiles.shtml
Comment 14 poopsmith CLA 2011-08-28 11:09:18 EDT
I figured out one reason/cause why this might be happening on Windows: the repo contains files with unacceptable filenames e.g. '*.jpg' or '&.jpg'.

(It's always a good idea to run 'git clone' in the default console and read the error message if there is any. That's how I figured out this.)
Comment 15 Robin Rosenberg CLA 2013-01-01 18:12:38 EST
I this still valid?
Comment 16 Matthias Sohn CLA 2013-01-12 05:01:10 EST
this is fixed since 0.12 with egit commit f3108b59f9e9059cc2e3032ae62cf51a57286285 which ensures that the repository is closed before calling FileUtils.delete is called. Note this can only happens if CloneOperation fails.