9

I'm using VS Code with Git - it's in portable location C:\_DEV\bin\git and is also added to Windows PATH so it works just fine with no remotes.

I have a OneDrive _GIT folder where I have some of my "remote" repositories, that sync between 2 devices (sometimes, I have it there mainly for backup purposes).

The error appears when I want to commit changes, only way to "fix" this issue is to restart the computer, so I'd like to find a way how to fix it properly. The problem is, it doesn't appear always and not for all repositories, it's pretty random.

I think it's because of sync from/to OneDrive. Is there a command I can run to fix the file descriptor? Or other way to prevent it?

git remote --verbose
git ls-tree -l HEAD -- a:\new\theme\assets\sass\main.scss
git show 97a333c5e7fce816dbb46a5c1235d69e61836726
git show HEAD:theme/assets/sass/main.scss
git add -A -- a:\new\theme\assets\sass\main.scss
fatal: fsync error on 'sha1 file': Bad file descriptor
moped
  • 2,197
  • 2
  • 24
  • 30
  • 2
    The proper solution is not to store your Git repositories on network drives. (I'm not trying to be snarky. This is explicitly _not_ a supported scenario.) – Edward Thomson Dec 21 '17 at 21:26
  • But this is not a network drive, it's my local drive and it's synced to OneDrive cloud storage .. – moped Dec 21 '17 at 21:39
  • 1
    I have the same problem when using a local drive mapped to virtual machine and GIT in that VM. Apparenlty it is caused by GIT, because I don't use VS Code. – Al Kepp Dec 27 '17 at 14:58
  • I've also had the problem with this fails in `Visual Studio Code` while the main repository is open in another tool, like `Visual Studio 2019`. Try closing `Visual Studio 2019` and see if it resolves the issue. – AlainD Dec 01 '20 at 16:59
  • Do you have a source for that @EdwardThomson? I have been unable to find any evidence that your claim is true. – clbx Apr 22 '21 at 13:29

8 Answers8

15

Thanks to @edward-thomson.
I had same problem on my PC, where i mapped a folder under my homedrive to E:

C:\Users\myuserid\E-Folder\SomeGitProject

by sharing the folder, so i could shortcut it to

E:\SomeGitProject

Solution was to use the full path in CMD or use the shortcut to homedrive from git bash:

~/E-Folder/SomeGitProject

I guess your A: likewise is a share, that you can access with a full path probably also located somewhere under your homedrive.

RaSor
  • 869
  • 10
  • 11
  • 1
    Thanks, after long testing I found no issue with OneDrive, but the problem was in folder mapped to drive as you suggested. So instead of having drives A B Y now I have folders A_DEV, B_DEV, Y_DEV, same functionality, just without sharing and drives.. – moped Feb 26 '18 at 16:51
9

I am posting late to help others get to the solution faster than I did. The actual culprit was elusive, and I tried everything from re-installing GIT to creating new repositories.

This happened to me in windows and it was due to a change in permissions in a parent folder somewhere.

The solution was to simply disconnect and remap the folder.

James Bailey
  • 498
  • 6
  • 19
  • 1
    yes, it's a problem when you map a drive. instead of mapping the drive, make it a special folder in My Computer so you have same quick access just without git issues – moped Aug 23 '18 at 13:04
  • Same happened with me, the error message was `fatal: fsync error on 'loose object file': Bad file descriptor` Possible solution is to change ownership of the parent folder. – Braza Sep 09 '19 at 14:51
  • For context, my Hyper-V VM has a drive mapped to a host machine shared directory. Using the **exact same setup** (i.e. *SourceTree*, files stored on mapped drive, *BitBucket* account, etc.)... `RepositoryA` works without issue, and `RepositoryB` will generate a `fsync error` when I to stage files. **Solution:** disconnect & remap drive worked for me as well. Now both `RepositoryA` and `RepositoryB` work. – Pressacco Nov 19 '19 at 18:51
  • 2
    5 minutes after my previous post, the `fsync error` re-appeared. I have a sneaking suspicion that it might be related to running *Visual Studio* and *SourceTree* at the same time on the same repository. I have never had an issue with this in the past. – Pressacco Nov 19 '19 at 19:04
  • 1
    @Pressacco, that latest one was the issue for me (almost three years later). Or, more specifically in my case, one instance of VS2019 and one of VS2022 at the same time. I closed down VS2022, and the problem went away immediately. – Boise Sep 15 '22 at 10:10
5

I have had this error a lot recently, and the above answers helped, but another thing that also seems to cause it is VS itself running.

Try closing VS, then doing a "Git Bash Here" from Explorer and using the command line only.

Once done you can then reopen VS.

Whelkaholism
  • 1,551
  • 3
  • 18
  • 28
  • I kept receiving the `fsync` error using from both *Visual Studio* and *Source Tree*. As per @Whelkaholism suggestion, I closed both applications and created the commit via the *Git Bash*. It worked! FYI - rather than stage one file at a time for the commit, this command helped: `git add $(git rev-parse --show-toplevel)` – Pressacco Mar 26 '20 at 12:31
2

I also have mapped my root webspace as a drive. This is no problem until files are watched (like with npm run watch).

Jona
  • 1,156
  • 10
  • 16
  • yes that's possible. I develop with Prepros so the project folder is nonstop watched by it .. but I don't have these issues anymore. I've mapped my "www" folder as Custom Folder with ThisPCTweaker (it appears same as Downloads or Desktop in My Computer) – moped May 24 '20 at 14:47
2

I faced same issue. I just resolved this issue with the following steps:

1- Close Visual Code

2- Open project on git bash command line

3- Commit the code again

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320
azeem
  • 341
  • 3
  • 4
1

I had the same problem with visual studio 2017. My solution was to close visual studio, then open Visual studio CODE and merge the files there.

Maxter
  • 716
  • 7
  • 15
0

Restarting VS Code works. A bit easier than disconnecting and re-mapping the folder (which also works).

Nathan Clement
  • 1,103
  • 2
  • 18
  • 30
  • 1
    maybe works for you, but definitely not for me :) that was the first thing I tried ... – moped May 07 '19 at 21:43
0

I just had the same problem. In my case the problem was low disk space. Hope this helps someone.

Beslo
  • 1
  • 1