Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixing the "Failed to save" error in Visual Studio Code?

I recently installed Visual Studio Code 1.72.2 on a Windows 10 OS.

Since I started using it, I had a hard time when saving source files in VS Code, with the error message very frequently appearing and saying "Failed to save 'Test.py': Unable to write file '[file_path]' (Unknown (FileSystemError): Error: UNKNOWN: unknown error, open '[file_path]')"

When I create a workspace and the first source file, it actually saves without a problem. Then, after about 5-10 minutes of editing and debugging, the aforementioned error message suddenly pops up and I can't save the file from there on.

enter image description here

After searching Google many times, I could only find one post written by someone who was probably in an identical situation as mine (identical problems like files becoming corrupted after experiencing this "Failed to save" error), but the post was closed without any useful information.

I could find some posts about having "Failed to save" type of errors like File Permission error, but since my error exclusively says "UNKNOWN" I can't even guess what went wrong.

I already have tried disabling the installed extensions, but still no luck. This error happens regardless of the language of the source files, hence it shouldn't be a problem with a particular extension.

One last note, the file system I am using for source files and workspaces is D:, which is a 256GB external USB Mass Storage Device.

Any suggestions would be appreciated.

like image 608
Mir Avatar asked Jun 28 '26 09:06

Mir


1 Answers

I was facing the exact same error. The error was instantly gone when I realised my git bash (MINGW64) was running in the editor mode as git diff command was running in it. This means bash couldn't input or output anything else before I pressed 'q' to exit. The issue was instantly gone. The command can be any that involves the terminal or bash to go into the editor mode.

like image 136
Sunpreet Kochhar Avatar answered Jun 30 '26 05:06

Sunpreet Kochhar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!