Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create .git/index.lock #64

Closed
svenlombaert opened this issue Aug 23, 2017 · 24 comments

Comments

@svenlombaert
Copy link

commented Aug 23, 2017

Hello @carloscuesta 馃槑!

Since a while now, every time I commit (I have the pre-commit hook installed), after it, I get this message:

ERROR: fatal: Unable to create '/Projects/pathname/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

I've tried removing and installing the pre-commit hook, removed gitmoji-cli completely and updated to the most recent version - nothing helps. I encounter the same problem without pre-commit hook and just using the gitmojicommand. When I just commit normally (without gimoji) everything works fine 馃憣 .

Any ideas?

KR

@Seaony

This comment has been minimized.

Copy link

commented Aug 27, 2017

I also met the same problem, did you find the solution?

@carloscuesta

This comment has been minimized.

Copy link
Owner

commented Aug 27, 2017

Related with #9 #10 #62

What OS are you using?

Seems like a common issue so I will take a look to fix it

@carloscuesta carloscuesta added the bug label Aug 27, 2017

@svenlombaert

This comment has been minimized.

Copy link
Author

commented Aug 28, 2017

MacOS Sierra, Version 10.12.6 (16G29)

Thanks!

@samirdhebar

This comment has been minimized.

Copy link

commented Aug 30, 2017

I also am having the same issue on Linux regarding this commit issue. I reviewed the earlier fix but sadly to no avail 馃槩

@LBreda

This comment has been minimized.

Copy link

commented Sep 1, 2017

Same here, on Linux. The lockfile doesn't actually exist.

@gluons

This comment has been minimized.

Copy link

commented Sep 10, 2017

Me too. On Kubuntu 17.04. It happened sometime.
I have no any hooks.

_002

@gluons

This comment has been minimized.

Copy link

commented Sep 24, 2017

Did anyone found the cause of this problem? 馃
I frequently face this problem but I can't find why it happened. 馃槙
Try to find index.lock file in my .git folder but it doesn't exist. 馃檮

@carloscuesta

This comment has been minimized.

Copy link
Owner

commented Sep 24, 2017

As the error messages says, this problem comes from:

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

And basically this happens when a git process is killed therefore the lock file is left over.

I've been investigating and I haven't found a solution yet. It's really weird because it's hard to reproduce the error. IMHO I think the issue is related with use of the hook option

gitmoji-cli/src/gitmoji.js

Lines 108 to 113 in ea99b51

_hook (answers) {
const title = `${answers.gitmoji} ${answers.title}`
const reference = (answers.reference) ? `#${answers.reference}` : ''
const body = `${answers.message} ${reference}`
fs.writeFileSync(process.argv[3], `${title}\n\n${body}`)
}

It really never happened to me, at least with gitmoji-cli. I've faced this issue (when cancelling a pull, commit etc.) while using the basic git command and I've fixed it by running:

rm -rf .git/index.lock

Any help is appreciated! 馃憤

@gluons

This comment has been minimized.

Copy link

commented Sep 24, 2017

it's hard to reproduce the error

Agree. I can't predict when it'll happen. I happen randomly. (even if I don't cancel any commit) 馃槾

@carloscuesta

This comment has been minimized.

Copy link
Owner

commented Sep 24, 2017

@gluons @svenlombaert @Seaony @samirdhebar @LBreda

I've created a branch at lab-fix-index-lock @ ab31066 to test out some fixes, could you please try to install the cli from this branch and see if the problem persists?

$ npm i -g git://github.com/carloscuesta/gitmoji-cli.git#lab-fix-index-lock
@gluons

This comment has been minimized.

Copy link

commented Sep 24, 2017

@carloscuesta OK. I'll use this version instead of NPM version now.

Off topic: That version no longer has default CLI action? 馃槄

_004

@carloscuesta

This comment has been minimized.

Copy link
Owner

commented Sep 24, 2017

@gluons

This comment has been minimized.

Copy link

commented Sep 24, 2017

Oh! Sorry. The fresh version. I haven't read it. My fault. 馃槄

@gluons

This comment has been minimized.

Copy link

commented Sep 25, 2017

It still happen. 馃槩

default

default

@luane91

This comment has been minimized.

Copy link

commented Jan 2, 2018

In Android Studio I solved this issue by adding the location of my project directory in: (Android Studio) File>Settings>Version Control

then add the path of your project directory and the version control you are using.

@rumblefrog

This comment has been minimized.

Copy link

commented Mar 13, 2018

An interesting thing is that if you create index.lock manually and try to commit, it'll emit the error message twice.

@rumblefrog

This comment has been minimized.

Copy link

commented Mar 14, 2018

I'm constantly getting this specific error on this repo: https://github.com/sbpp/sbpp.github.io

But not any others, not sure what's different

@ppartarr

This comment has been minimized.

Copy link

commented Apr 21, 2018

If you are using an IDE try disabling source control and refreshing

@martinfengshenxiang

This comment has been minimized.

Copy link

commented Jun 4, 2018

I'am also don't have the index.lock file.
when I am running git add --all & git commit -m 'add some file', get the error.
But after I running each command seperately, problem solved!
I runned:
git add --all git commit -m 'add some file'
just like magic馃槉

@muwoo

This comment has been minimized.

Copy link
Contributor

commented Jul 9, 2018

@martinfengshenxiang yeah! That's true! gitmoji -c whill running git add . & git commit -m '' default.
so I run gitmoji -g and choose N to close git add .

image

After that, just fine.

muwoo added a commit to muwoo/gitmoji-cli that referenced this issue Jul 9, 2018

@muwoo muwoo referenced this issue Jul 9, 2018

Merged

Fix thow 'Unable to create .git/index.lock' #109

1 of 1 task complete
@svchraghava

This comment has been minimized.

Copy link

commented Jul 28, 2018

I also face the same issue in windows.

image

@svchraghava

This comment has been minimized.

Copy link

commented Jul 28, 2018

It resolved for me.

  1. show the hidden files in local repository
  2. you will find .git folder in your local repository
  3. in side .git there will be a file index.lock
    4.delete that index.lock file, it will work for you

how to show hidden files

  1. go to explorer click on Organise as below

image

  1. select Folder and search options, you will go below location
    image

  2. go to view tab, select the radio button show hidden files and folders.
    image

@JSteunou

This comment has been minimized.

Copy link

commented Sep 18, 2018

I'am also don't have the index.lock file.
when I am running git add --all & git commit -m 'add some file', get the error.
But after I running each command seperately, problem solved!
I runned:
git add --all git commit -m 'add some file'
just like magicblush

I think that's because it should be git add --all && git commit -m 'add some file' with a double & if you wanna run the cmds separately

@ETLaurent ETLaurent referenced this issue Sep 18, 2018

Open

Add auto on empty stage option #128

1 of 1 task complete
@ZakirBalti

This comment has been minimized.

Copy link

commented Dec 24, 2018

try to delete the Exist lock file then issue will be resolve
rm -f .git/index.lock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.