git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG REPORT] Intermittent errors: Unable to create '/usr/ports/.git/index.lock': File exists.

From
Jeff King <peff@peff.net>
Date
Sep 9, 2021, 20:19 UTC
Message-ID
<YTpsQtJa2rX691c0@coredump.intra.peff.net>
In-Reply-To
<1fcdeb8f-5869-cfe4-6063-8d4fb5da709c@rawbw.com>
On Thu, Sep 09, 2021 at 12:29:32PM -0700, Yuri wrote:
Show 13 quoted lines
> Once every ~20 times I call 'git commit' it fails like this:
> 
> $ git commit .
> fatal: Unable to create '/usr/ports/.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.
> 
> 
> There's no other instance.

In previous cases of this we've seen, there usually _is_ another instance, just not one directly triggered by the user. E.g., some GUI clients will trigger "git status" in the background, which tries to refresh the index.

If you're running any other Git-related tools (or anything via cron), those might be worth investigating. Otherwise you might try using OS tools to see which processes might be opening such a file (on Linux I'd use inotifywait, but I'm not sure what's available on FreeBSD).

If you do find the culprit, one solution is to get it to use the "--no-optional-locks" option. See the discussion of that option and GIT_OPTIONAL_LOCKS in git(1), as well as the "BACKGROUND REFRESH" section of git-status(1).

-Peff
Previous: Yuri
Message 2 of 2 in “[BUG REPORT] Intermittent errors: Unable to create '/usr/ports/.git/index.lock': File exists.”
  1. YuriSep 9, 2021
  2. Jeff KingSep 9, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.