This is something that has bugged me with XCode for years, and unfortunately, I'm experiencing the same issue with VS.
Typical use case:
You can see that VS attempts to update the git view, even though it hasn't got the focus.
This leads to git operation in the terminal failing due to:
fatal: Unable to create '/Users/jyavenard/Work/Mozilla/mozilla-central/.git/index.lock': File exists. As you can only have one git operation going at a time.
While the likelihood of the failure to occur appears to be much lesser than with xcode, I still get it occasionally.
Solution: VS shouldn't attempt to perform a git operation, unless it has the focus.
Since a few releases already, Code doesn't update the git view if it's not in focus.
Are you sure you still see this in 1.5.2? My Code stays put, until I focus it.
Yes I'm certain...
If VS Code is showing up by the side of the terminal window, in its git view (while the focus is on the terminal window) you can see the list of staged files being refreshed while the rebate is in progress.
Version and platform used are in the original message.
Is this the internal terminal? Or something like Terminal.app or iTerm.app?
it is terminal.app started outside of VS.
Could it be due to some of the git extension I have installed?
I have
https://marketplace.visualstudio.com/items?itemName=donjayamanne.githistory
https://marketplace.visualstudio.com/items?itemName=bibhasdn.git-easy
and:
https://marketplace.visualstudio.com/items?itemName=waderyan.gitblame
Mind you, if I modify manually a file outside VS Code (and one in git), neither the editor nor git view show an updated content.
But when rebasing, I can see the file being staged changing in the VS Code code view, even though it doesn't have the focus.
I could reproduce! Definitely a bug, thanks for the persistence, @jyavenard!
I also experienced this issue with vscode on Linux and using git from a terminal.
I can no longer reproduce this... But I did a code change which might affect your scenario, @jyavenard. Let me know how it goes.
If you're referring to the version 6.1
I had it happening just a few hours ago...
I see a 'git fetch' in the Output's git channel and monaco.d.ts come and go in the Git viewlet without Code having focus. I'm running npm run watch and git rebase ... in a terminal window. Reopening.
| Extension | Author | Version |
| --- | --- | --- |
| dart-code | DanTup | 0.13.0 |
| EditorConfig | EditorConfig | 0.3.3 |
| vscode-docker | PeterJausovec | 0.0.6 |
| speech | bierner | 0.0.1 |
| regex | chrmarti | 0.0.6 |
| vscode-eslint | dbaeumer | 1.0.7 |
| python | donjayamanne | 0.5.0 |
| ghlink | dt | 0.0.4 |
| gitlens | eamodio | 0.5.5 |
| tslint | eg2 | 0.5.39 |
| vsc-travis-ci-status | felixrieseberg | 1.0.3 |
| PowerShell | ms-vscode | 0.7.2 |
| cpptools | ms-vscode | 0.9.2 |
| csharp | ms-vscode | 1.4.1 |
| debugger-for-chrome | msjsdiag | 1.1.0 |
| diff | rafaelmaiolla | 0.0.1 |
| kustovscode | seanmcbreen | 0.0.1 |
| vscode-open-in-github | sysoev | 1.2.0 |
git fetch is OK. Files coming and going are not. I'm still unable to repro, but I'll take a closer look.
Are you sure they are?
Because whenever I'm getting those .git.lock error, at no time vscode is writing on the repo.
Not like two writing operations are occurring in parallel...
I don't know if there has been any changes recently along the lines of this issue, but I'm running 1.8.0-insider (2016-11-23) on Win7 and the vscode git refresh is taking forever now even if the window has focus. I can commit some files in a separate terminal, go back to vscode and easily wait 30-60 seconds before the git information is correct.
@dlong500 How slow is git status in the command line? Code will react to outside changes and call git status to update its state. It won't call it more often than every 10 seconds though... so there might be a 10 second delay, once focused. 30-60 is way too much. You can check the Git Output within Code to track what it's doing.
I got error with index.lock file without terminal. Just choosed "Pull (Rebase)" from menu.
Looks like it was executed in same time with "git.exe status -z -u" of "git fetch" or other (hidden?, without got output log) "git.exe status -z -u" of "Code.exe"? (based on logs)
Plus while "git pull --rebase" is working, VSCode output temporary files in Git tab + temporary branch in status bar.
As possible solution: Can you execute any background git subprocess only if Code.exe has not any other git subprocess (any level of "sub", including Code.exe/terminal/git.exe)?
@joaomoreno I've tested further and it appears what is happening is that vscode won't refresh the git status at all until I switch panes or files (even if the app has focus). So, for example, if I am looking at the Git pane in vscode showing changes and then I take some git action outside of vscode nothing will happen even when I bring the focus back to vscode unless I do something like switch panes or editors. This is still happening with the latest insider version as of this afternoon.
I'm on VSCode v1.12.1 for Mac and I'm experiencing the same issue when I try to use Git from the terminal, usually when doing a merge:
fatal: Unable to create '.../path/to/project/.git/index.lock': File exists.
I can fix this by focusing VSCode and quitting it.
VSCode shouldn't hijack Git, especially if it's not in use, and even more so if the Git pane is not even in focus in VSCode.
Yeah, the same issue
fatal: Unable to create '.../path/to/project/.git/index.lock': File exists.
It seems VSCode doesn't release the lock file properly......
I'm experiencing the same issues while working with VSC. I can't use any other program like SourceTree or GitKraken because VSC keeps hijacking the index.lock file.
Please fix this, I've lost commit contents several times because VSCode took the lock during rebases and I probably didn't abort or continue correctly.
I have to quit VSCode every time I want to rebase, because of that I'll probably have to switch to another editor. (I'm on Mac, VSCode v1.13.1
@XavCamp
As temporary solution, you can setup in settings:
"git.autorefresh": false,
"git.autofetch": false,
Thanks @SailorMax, I had autofetch to false but I missed autorefresh, I'll give it a try
1 year and 8 months since this was reported in #901, it is still a major blocker for using VSCode at work. Hopeful for next milestone! 馃
@ricardobeat It was actually fixed during most of that time and broke recently when we moved git to an extension. But we're always happy to have pressuring passion. :+1:
I just started using VSC this week and have been seeing the fatal: Unable to create [...]/.git/index.lock': File exists error fairly often while trying to do git rebase or git status in an external terminal. I'm using Ubuntu 14.04 with Git 2.13.0 and Visual Studio Code 1.14.2. I'm going to disable git.autorefresh (and probably git.autofetch) for now.
One final comment on this closed issue. The atom developers have gotten a commit accepted to the git codebase that prevents git status from grabbing git/index.lock when --no-optional-locks or GIT_OPTIONAL_LOCKS=0 is specified. This seems like the best long-term solution for vscode and its extensions.
https://public-inbox.org/git/[email protected]/
@joelhock This is awesome, thanks for the update! Created #35513 to track this.
still happening in Version 1.17.1 (1.17.1
Most helpful comment
still happening in Version 1.17.1 (1.17.1