https://github.com/microsoft/WSL2-Linux-Kernel/issues/168 Skip to content Sign up * Why GitHub? Features - + Code review + Project management + Integrations + Actions + Packages + Security + Team management + Hosting + Mobile + Customer stories - + Security - * Team * Enterprise * Explore + Explore GitHub - Learn & contribute + Topics + Collections + Trending + Learning Lab + Open source guides Connect with others + Events + Community forum + GitHub Education + GitHub Stars program * Marketplace * Pricing Plans - + Compare plans + Contact Sales + Nonprofit - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} microsoft / WSL2-Linux-Kernel * Watch 162 * Star 4.4k * Fork 366 * Code * Issues 125 * Pull requests 22 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights 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. Pick a username [ ] Email Address [ ] Password [ ] [ ] Sign up for GitHub By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails. Already on GitHub? Sign in to your account Jump to bottom Did WSL2 corrupt my git repository? #168 Open skhaz opened this issue Aug 3, 2020 * 46 comments Open Did WSL2 corrupt my git repository? #168 skhaz opened this issue Aug 3, 2020 * 46 comments Comments @skhaz Copy link Quote reply @skhaz skhaz commented Aug 3, 2020 I recently switched my development enviroment from macOS to Windows and I am using WSL2 on my machine with VSCode and WSL2 remote extension. Everthing was fine when today I got this error message from git $ git pull error: object file .git/objects/f8/72e0c57726ea0b5456269eebd81dd78f625980 is empty fatal: loose object f872e0c57726ea0b5456269eebd81dd78f625980 (stored in .git/objects/f8/72e0c57726ea0b5456269eebd81dd78f625980) is corrupt $ git status error: object file .git/objects/f8/72e0c57726ea0b5456269eebd81dd78f625980 is empty error: object file .git/objects/f8/72e0c57726ea0b5456269eebd81dd78f625980 is empty error: object file .git/objects/f8/72e0c57726ea0b5456269eebd81dd78f625980 is empty fatal: loose object f872e0c57726ea0b5456269eebd81dd78f625980 (stored in .git/objects/f8/72e0c57726ea0b5456269eebd81dd78f625980) is corrupt Any clues? The text was updated successfully, but these errors were encountered: 28 10 @microhobby Copy link @microhobby microhobby commented Aug 3, 2020 @skhaz are you using through the Linux file system or the Windows file system? @skhaz Copy link Author @skhaz skhaz commented Aug 3, 2020 @microhobby through the Linux file system. All my code, git, tools and compilers are on Linux side. 4 @skhaz skhaz changed the title [DEL:Does WSL2 corrupted my git repository?:DEL] [INS:Did WSL2 corrupted my git repository?:INS] Aug 3, 2020 @skhaz skhaz changed the title [DEL:Did WSL2 corrupted my git repository?:DEL] [INS:Did WSL2 corrupt my git repository?:INS] Aug 3, 2020 @2n3906 Copy link @2n3906 2n3906 commented Aug 27, 2020 This exact thing happened to me. I'm also running WSL2 with Git on the Linux filesystem using VS Code to edit. 24 @2n3906 Copy link @2n3906 2n3906 commented Sep 16, 2020 And it just happened to me again. I haven't put together a rigorous timeline but this is happening on a laptop that goes to sleep--and possibly into a hibernate state--prior to the corruption. I will try to take better notes next time it happens. 2 @PulsarFox Copy link @PulsarFox PulsarFox commented Sep 17, 2020 * edited I'm not on a laptop, and I have this error message everytime on a git repo, did a find .git/objects/ -size 0 -delete But then I had theses messages error: refs/heads/develop does not point to a valid object! error: refs/remotes/origin/develop does not point to a valid object! I pulled the project and now everything is fine, I didn't push yet so i hope it wont corrupt my remote branch too Edit: Nothing has been corrupted 1 @skhaz Copy link Author @skhaz skhaz commented Sep 23, 2020 Just out of curiosity, are you guys using VSCode's terminal or something else? @PulsarFox Copy link @PulsarFox PulsarFox commented Sep 23, 2020 VSCode Integrated wsl terminal yes. Opened the project with the command code . inside the project folder @2n3906 Copy link @2n3906 2n3906 commented Sep 23, 2020 I was using VS Code inside WSL2 to edit files, but doing git directly from the latest Windows Terminal. @skhaz Copy link Author @skhaz skhaz commented Sep 23, 2020 Hmm... I have a suspicious, can be VSCode's fault, not sure, never happened to me again. @Annih Copy link @Annih Annih commented Oct 22, 2020 Hum it happens to me multiple times recently, and I'm not using VSCode. It seems that it happens when I'm a bit too quick to close my WSL session (sometimes with a wsl shutdown) but not only. @Champkinz Copy link @Champkinz Champkinz commented Nov 11, 2020 Is there any direct solution for this, this happens once a day for me! @sidharthramesh Copy link @sidharthramesh sidharthramesh commented Nov 12, 2020 Happens to me too @skhaz Copy link Author @skhaz skhaz commented Nov 12, 2020 @sidharthramesh @Champkinz try to disable fast boot, never happened again. 2 @edrevo Copy link @edrevo edrevo commented Nov 13, 2020 Related issues: microsoft/WSL#5026 microsoft/WSL#5895 1 @Champkinz Copy link @Champkinz Champkinz commented Nov 13, 2020 @skhaz So far no issues, but I managed reproduce the problem once, if I shutdown the PC while VSCODE is open , the git gets corrupted, but I tried like 3 times, only once the git got corrupted. just leaving this here for future reference. 2 @mbrumlow Copy link @mbrumlow mbrumlow commented Dec 15, 2020 Just want to chime in, switching form a full Linux setup (actually installed windows for the first time in 15 years). And today I had my first corrupt git repo. I use X with Emacs, and the command line only. No fancy external tools. The error indicated a object file simply went missing. I suspect that some sort of optimization is keeping the fs from flushing. As the night before I had committed, and pushed, then installed a windows update that required a reboot. Today I continued working and wen i went to commit produced the object missing error. 1 [?] 4 @Champkinz Copy link @Champkinz Champkinz commented Dec 16, 2020 After disabling fast boot, my issue was completely fixed. @luigimannoni Copy link @luigimannoni luigimannoni commented Dec 28, 2020 Disabling fast boot didn't help in my case, corruptions are more or less constant with fast boot switched on or off. 4 @skhaz Copy link Author @skhaz skhaz commented Dec 30, 2020 It happened again, but this time with bash history got corrupted. @Champkinz Copy link @Champkinz Champkinz commented Dec 30, 2020 My bash history keeps getting corrupted every now and then, but not my git. Yesterday my whole npm package got misplaced or something , had to fix the path and reinstall it. Feel like booting Linux on a separate disk because of these issues. This is why mac is convenient when it comes to development. 19 18 4 1 2 @edrevo edrevo mentioned this issue Dec 30, 2020 Wsl2 sometime corrupt .zsh_history and git microsoft/WSL#5026 Open @jmfury Copy link @jmfury jmfury commented Jan 1, 2021 * edited I have disabled fast boot and the .git issue (error: object file ... is empty & fatal: loose object ... is corrupt) is still occurring @JasonYangShadow Copy link @JasonYangShadow JasonYangShadow commented Jan 2, 2021 WSL2 uses a hypervisor machine? this issue might be caused by the virtual disk? @QEDK Copy link @QEDK QEDK commented Jan 2, 2021 * edited Fwiw, I have used WSL2 (latest Debian and Kali) without VSCode for ~6 months and this hasn't happened to me once - maybe because I never shutdown my laptop? @dscho Copy link Member @dscho dscho commented Jan 2, 2021 Have you tried fiddling with core.fsyncObjectFiles? 2 @runvnc Copy link @runvnc runvnc commented Jan 2, 2021 Is there any direct solution for this, this happens once a day for me! Use actual Linux such as Debian, Ubuntu or Pop OS. If necessary, you can run Windows inside VirtualBox. Or run Windows programs with Wine, Proton etc. And it doesn't corrupt your file system. 32 53 13 [?] 7 3 @Champkinz Copy link @Champkinz Champkinz commented Jan 2, 2021 Is there any direct solution for this, this happens once a day for me! Use actual Linux such as Debian, Ubuntu or Pop OS. If necessary, you can run Windows inside VirtualBox. Or run Windows programs with Wine, Proton etc. And it doesn't corrupt your file system. This is gonna be my solution 19 3 @luigimannoni Copy link @luigimannoni luigimannoni commented Jan 2, 2021 * edited Is there any direct solution for this, this happens once a day for me! Use actual Linux such as Debian, Ubuntu or Pop OS. If necessary, you can run Windows inside VirtualBox. Or run Windows programs with Wine, Proton etc. And it doesn't corrupt your file system. While I would do this for a tower/desktop that isn't an helpful solution for a laptop. Mind that I come from a Ubuntu distro, Windows is the most energy efficient solution at the moment and allows me to run my Dev tools and work on battery for 4 hours straight. Ubuntu (or any Debian-based distro) destroy my battery in 40 minutes and there's no solution or optimization for that. 9 17 5 @timvisee Copy link @timvisee timvisee commented Jan 2, 2021 * edited I don't think there is space here for a Windows versus Linux discussion. This is something that should be fixed, likely on the Windows side of things, and shouldn't need workarounds. The cause of this issue might be rooted in Hyper-V's mounts. 39 1 @anaisbetts Copy link @anaisbetts anaisbetts commented Jan 2, 2021 * edited This is a dupe of microsoft/WSL#5026, you can work around it by making sure not to use shutdown /r /t 0 to shut the machine down. WSL isn't getting shut down properly on your computer and you're doing the equivalent of yanking the power on the device 1 2 @QEDK Copy link @QEDK QEDK commented Jan 2, 2021 Is there any direct solution for this, this happens once a day for me! Use actual Linux such as Debian, Ubuntu or Pop OS. If necessary, you can run Windows inside VirtualBox. Or run Windows programs with Wine, Proton etc. And it doesn't corrupt your file system. This is not a solution for people who intend to use WSL2. And chances are people who don't want to use it already use something else. 16 @luigimannoni Copy link @luigimannoni luigimannoni commented Jan 2, 2021 This is a dupe of microsoft/WSL#5026, you can work around it by making sure not to use shutdown /r /t 0 to shut the machine down. WSL isn't getting shut down properly on your computer and you're doing the equivalent of yanking the power on the device Unfortunately that is not the case to many, this happens personally to me pretty much by shutting down the computer by using the shutdown button in the start menu. The problem appears also while entering and exiting standby and rebooting through windows update 4 @jeremyBanks Copy link @jeremyBanks jeremyBanks commented Jan 2, 2021 This happens frequently if I accidentally interact with the same files from both the Windows and Linux side in close succession. I never explicitly shut down WSL. Some files seem to get stuck in a locked state that doesn't clear until I reboot the machine, while other files are not, and the result is an inconsistent/corrupt repo or project. @ankushnarula Copy link @ankushnarula ankushnarula commented Jan 2, 2021 For those experiencing this issue, have you tried testing using the sync and/or halt commands before exiting WSL2? @timvisee This comment was marked as off-topic. Sign in to view @ankushnarula Copy link @ankushnarula ankushnarula commented Jan 2, 2021 @ankushnarula Some suggested shutdown, apparently with no effect. That implicitly does the same thing, syncing the underlying file system. Yes - implicitly. Which is why I asked if anyone tried it explicitly. ;-) @chx chx mentioned this issue Jan 2, 2021 LLDB can't launch process microsoft/WSL#2028 Closed @riverar Copy link @riverar riverar commented Jan 2, 2021 * edited This is a dupe of microsoft/WSL#5026, you can work around it by making sure not to use shutdown /r /t 0 to shut the machine down. WSL isn't getting shut down properly on your computer and you're doing the equivalent of yanking the power on the device @anaisbetts shutdown /r /t 0 just triggers a normal shutdown and reboot, this is not an accurate description of what's going on at all. 1 1 @anaisbetts Copy link @anaisbetts anaisbetts commented Jan 2, 2021 * edited @riverar yes, on the Windows side. But the WSL VM isn't being shut down cleanly in this scenario - this is a bug in WSL 1 @ElTimablo Copy link @ElTimablo ElTimablo commented Jan 2, 2021 Is there any direct solution for this, this happens once a day for me! Use actual Linux such as Debian, Ubuntu or Pop OS. If necessary, you can run Windows inside VirtualBox. Or run Windows programs with Wine, Proton etc. And it doesn't corrupt your file system. While I would do this for a tower/desktop that isn't an helpful solution for a laptop. Mind that I come from a Ubuntu distro, Windows is the most energy efficient solution at the moment and allows me to run my Dev tools and work on battery for 4 hours straight. Ubuntu (or any Debian-based distro) destroy my battery in 40 minutes and there's no solution or optimization for that. There is a solution for that: turn off your dedicated GPU, because that's the only possible way I can see that happening on Ubuntu. Going around crowing about the lack of a solution just shows how little you actually care about fixing it. 1 11 @riverar Copy link @riverar riverar commented Jan 2, 2021 @anaisbetts If that's true, it would also shutdown incorrectly during servicing, Start > Power > Restart, and app install. Or are you saying that's the bug? If so, that's a pretty serious oversight! @cmurf Copy link @cmurf cmurf commented Jan 2, 2021 * edited Folks having this problem could search the systemd journal for: systemd-fsck[681]: /dev/vdb2: recovering journal EXT4-fs (vdb2): recovery complete Either being present supports the hypothesis that the file system is not being cleanly unmounted. Or possibly the host side cache isn't being flushed to stable media. Edit: just saw this microsoft/WSL#5895 and that's not good. 2 @piscisaureus Copy link @piscisaureus piscisaureus commented Jan 2, 2021 This has happened to me in WSL1 too when I moved a large repo from / mnt/c/some/repo to ~/repo using Linux mv. @luigimannoni Copy link @luigimannoni luigimannoni commented Jan 2, 2021 Is there any direct solution for this, this happens once a day for me! Use actual Linux such as Debian, Ubuntu or Pop OS. If necessary, you can run Windows inside VirtualBox. Or run Windows programs with Wine, Proton etc. And it doesn't corrupt your file system. While I would do this for a tower/desktop that isn't an helpful solution for a laptop. Mind that I come from a Ubuntu distro, Windows is the most energy efficient solution at the moment and allows me to run my Dev tools and work on battery for 4 hours straight. Ubuntu (or any Debian-based distro) destroy my battery in 40 minutes and there's no solution or optimization for that. There is a solution for that: turn off your dedicated GPU, because that's the only possible way I can see that happening on Ubuntu. Going around crowing about the lack of a solution just shows how little you actually care about fixing it. This is not quite the place for the discussion as someone pointed, I've gone great lengths to minimise battery consumption and yes, that included switching off my dedicated GPU or tweaking configs to no end. My point was about remarking that "switch to a different os" is never a valid answer when someone points out a bug on a specific platform, both because one has reasons why it is using a specific operating system and because "use something else" doesn't solve the issue. Would you go buy a new car if your mechanic said that he can't unlock the door to your car? 10 1 @mohamedhaddi Copy link @mohamedhaddi mohamedhaddi commented Jan 2, 2021 Just out of curiosity, those having this issue which distro(s) are they using? I've been using Pengwin for around 6 months now and haven't had this particular problem (so far). But I do remember a weird (and terrifying) problem that happened to me once (some weeks ago), not sure if it's related to this one or caused by WSL at all, but it's similar in the sense that it happened after putting my laptop to sleep, a file that I've been working on for hours, of which I'm 100% sure was saved, I put my laptop to sleep and come back an hour later to find that the file is completely empty. Of course, I made the mistake of not making any commits or pushing it to a remote (although it was in a git repo), but also I'm not required to do that to keep my files, it's totally not my mistake that the content of a file that I've saved countless times is lost just like that, because that never happened and it's just not supposed to happen. So what caused it exactly? I have no idea, but all I know is that I was working on Neovim on Pengwin on WSL2. @okms Copy link @okms okms commented Jan 2, 2021 I work from a Debian image in WSL2 with files living on the Linux side. I've not experienced this issue at all as far as I can remember. I run the 4.19.128-microsoft-standard kernel. @lindsm Copy link @lindsm lindsm commented Jan 2, 2021 I don't have a lot of experience with WSL2, but just wanted to share mine in case it helps anybody. Will be pretty random. Recently, my work mac died from a dead battery. While it was in for repair, I used a C940 Yoga I had. I fresh installed Windows 10 on the Yoga, installed WSL2 & Ubuntu. Set Ubuntu as my default shell in the new "Windows Terminal", so no powershell usage unless for a windows command. I installed VS Code in windows, opened it from its shortcut, and used the settings sync. Once I was satisfied Code was functioning normally under Windows (all addons installed, no more update prompts), I used Windows Terminal to git clone a popular work repo. I opened code, in Windows Terminal, from that path using code .. VS Code installed some extensions to deal with WSL at this time; WSL Ubuntu-20.04... with some Python and Jupyter stuff included. Everything appeared to be working correctly. I could git clone, run python, and run python poetry successfully. I worked like this for about a month, would do my local development work, some minor python linting and testing, then push it up to a GitLab pipeline for full testing. I used the VS Code terminal, set to WSL2 Ubuntu bash, like this for about a month. Had many pushes to my teams repo with no issues. It was a popular repo, so errors would of been noticed right away. I know my laptop had gone to sleep during this, many times, with no issues. The laptop was my gaming rig as well, with an eGPU attached. So there was a lot of time with VS Code and Windows Terminal closed, never checked out the Windows Terminal got shut down, it just worked. Overall, for me, a pleasant work experience compared to trying to run linux on the temporary laptop sent to me, while still waiting for my mac to be repaired. @sangeeth96 Copy link @sangeeth96 sangeeth96 commented Jan 2, 2021 * edited This used to happen to me and my co-workers on Mac/WSL when you're using something that periodically syncs a repo (like a git fetch) and the process gets terminated forcefully or the system shut-down abruptly. If you're using VSCode, you should probably disable this (should be called something like "Autofetch") or if you are using some other program (maybe a feature of your shell?), might want to disable that as well. I had this happen when using WSL2 as well which ended up corrupting my git repo. Otherwise, I have been using WSL2 with VSCode for a long while and haven't had any issues. Not sure if there's some new update that's causing this if it's not due to the ones I mentioned. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Assignees No one assigned Labels None yet Projects None yet Milestone No milestone Linked pull requests Successfully merging a pull request may close this issue. None yet 27 participants @anaisbetts @jeremyBanks @skhaz @ankushnarula @dscho @okms @piscisaureus @2n3906 @runvnc @riverar @Annih @timvisee @mbrumlow @QEDK @lindsm @luigimannoni @edrevo @JasonYangShadow @microhobby @sangeeth96 and others * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Help * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.