Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333035

Summary: Unable to delete/remove resource since cannot lock index
Product: [Technology] EGit Reporter: Andre John Mas <andrejohn.mas>
Component: UIAssignee: Project Inbox <egit.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: jens.baumgart, mathias.kinzler
Version: 0.9.0   
Target Milestone: 0.11-M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Andre John Mas CLA 2010-12-21 14:04:56 EST
Build Identifier: M20100211-1343 

I am trying to delete a file, but I am getting told that the .git/index file cannot be locked. I am running on Windows XP, using EGit 0.9.3.

Message:

Error updating cache during move/delete.The resource cannot be moved, renamed or deleted due to an internal error.

Stack Trace :

java.io.IOException: Cannot lock C:\development\shadow\myproject\.git\index
at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:187)
at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:949)
at org.eclipse.egit.core.GitMoveDeleteHook.deleteFile(GitMoveDeleteHook.java:56)
at org.eclipse.team.internal.core.MoveDeleteManager.deleteFile(MoveDeleteManager.java:50)
at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1763)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:724)
at org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange.perform(DeleteResourceChange.java:138)
at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.access$0(DynamicValidationStateChange.java:1)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange$1.run(DynamicValidationStateChange.java:98)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4694)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.perform(DynamicValidationStateChange.java:101)
at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.access$0(DynamicValidationStateChange.java:1)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange$1.run(DynamicValidationStateChange.java:98)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4694)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.perform(DynamicValidationStateChange.java:101)
at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:260)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:308)
at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:92)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:220)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

Session Data (some values have been blanked out)
Eclipse.buildId=M20100211-1343
java.version=1.6.0_19
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -refresh eai -plugincustomization C:\xxxxxx\xxxx-global-eclipse-prefs.ini -showlocation
Command-line arguments:  -os win32 -ws win32 -arch x86 -refresh eai -plugincustomization C:\xxxxxx\xxxx-global-eclipse-prefs.ini -showlocation

I am not sure what the cause is. In the .git folder there is both an index and index.lock file (amongst others) and neither are locked and I have ownership permissions on both. I have only ever used this cloned git repository via EGit. This repository was cloned using EGit.

Should also note that this breaks commits:

org.eclipse.team.core.TeamException: Committing changes
	at org.eclipse.egit.core.op.CommitOperation$1.run(CommitOperation.java:181)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1782)
	at org.eclipse.egit.core.op.CommitOperation.execute(CommitOperation.java:192)
	at org.eclipse.egit.ui.internal.actions.CommitActionHandler$1.run(CommitActionHandler.java:187)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.io.IOException: Index file is in use
	at org.eclipse.jgit.lib.GitIndex.write(GitIndex.java:272)
	at org.eclipse.egit.core.op.CommitOperation.doCommits(CommitOperation.java:295)
	at org.eclipse.egit.core.op.CommitOperation.access$8(CommitOperation.java:281)
	at org.eclipse.egit.core.op.CommitOperation$1.run(CommitOperation.java:178)
	... 5 more


I have quit and restarted Eclipse to see if this changes anything, but it does not seem to.

This is currently acting as a blocker to me checking anything in. I could probably forcefully delete the index.lock file, but I am hesitant to do so.

Reproducible: Always
Comment 1 Andre John Mas CLA 2010-12-21 14:09:26 EST
i took a chance and deleting the index.lock file seem to have resolved the issue for now. Not sure why it had not been cleaned up, if it was no longer used?
Comment 2 Jens Baumgart CLA 2010-12-22 11:51:54 EST
Might be related to the following fix: http://egit.eclipse.org/r/#change,2165
Comment 3 Mathias Kinzler CLA 2010-12-30 04:18:33 EST
Merged(In reply to comment #2)
> Might be related to the following fix: http://egit.eclipse.org/r/#change,2165

This fix was merged as f4be686afac1849522706292e9c90fe6dcbfa5e5.

Please do not hesitate to re-open if the problem occurs again (but you have to use 0.11 to take advantage of the fix).