Skip to content
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.

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

Saving on Windows succeeds but shows error message dialog (due to file locking limitations) #6393

Closed
amedlock opened this issue Sep 4, 2016 · 61 comments

Comments

@amedlock
Copy link

amedlock commented Sep 4, 2016

Operating system or device - Godot version:
Windows 7 64 bit professional

Issue description (what happened, and what was expected):
Editing and saving a script repeatedly seems to cause the following error:
Unable to write to file 'e:/proj/myproject/script/test.tscn' , file in use, locked or lacking permissions.

This is in the log:
ERROR: FileAccessWindows::close: Condition ' rename_error ' is true.
At: drivers\windows\file_access_windows.cpp:139
ERROR: FileAccessWindows::close: Condition ' rename_error ' is true.
At: drivers\windows\file_access_windows.cpp:139

Steps to reproduce:
Just changing and editing a script file seems to cause it.

Link to minimal example project (optional but very welcome):

@amedlock
Copy link
Author

amedlock commented Sep 4, 2016

Looking further, this only happens when stopped with error in debugger.

@reduz
Copy link
Member

reduz commented Sep 6, 2016

do you have the script files opened by something else, like an external editor?

@vnen
Copy link
Member

vnen commented Sep 6, 2016

I've seen this, usually when the scene is running, but I can't reproduce reliably.

@IBwWG
Copy link

IBwWG commented Dec 10, 2016

For me the scripts are not open in a separate editor, and I was getting this sporadically but now it's just about every save. Godot 2.1.1 on win7x64.

@IBwWG
Copy link

IBwWG commented Dec 11, 2016

Also in my case often (but not always) the saving isn't succeeding. Obvious changes made etc. are not present in what's run.

Possible lead, TortoiseGit caching...could this have been the case for you @amedlock or @vnen ?

@IBwWG
Copy link

IBwWG commented Dec 13, 2016

Yeah this bug really slowed down my save/reload cycle....

@Sslaxx
Copy link

Sslaxx commented Dec 13, 2016

Perhaps this needs to be re-opened.

@IBwWG
Copy link

IBwWG commented Dec 13, 2016

I would say so...not to be a snob about it but I stuck it through for LD 37, but would not want to use Godot again until that was fixed. Not a show-stopper but a real grind-it-to-a-near-halt-er with no obvious workaround. It seemed like every 10th save sometimes, or sometimes every 2nd save, would just mysteriously work.

You're not supposed to run as admin or anything, are you?

@akien-mga akien-mga reopened this Dec 13, 2016
@amedlock
Copy link
Author

I had no TortoiseGit running, or Dropbox/Google drive. Seemed to just be windows holding the file handle sometimes.

@bojidar-bg
Copy link
Contributor

Isn't it that the currently running game is holding the file handle, or am I wrong?

@IBwWG
Copy link

IBwWG commented Dec 22, 2016

Sorry @bojidar-bg but it couldn't be that way even if I wanted to--my game captures the mouse, so I almost always exited it to return to the GUI, unless I was inspecting something in-game. I just tried it now to be sure, and the game definitely isn't running when I get the error.

@bojidar-bg
Copy link
Contributor

Then.. maybe the editor has the handle? 😄

@IBwWG
Copy link

IBwWG commented Dec 22, 2016

Then shouldn't it...you know...use it to save the file?

@bojidar-bg
Copy link
Contributor

@IBwWG All bugs are about a "shouldn't it", and this one is deep within drivers/windows probably.

@IBwWG
Copy link

IBwWG commented Dec 22, 2016

But, if Godot is still holding an open file handle, shouldn't it tell Windows to close it when it's done with it? (I have no idea if the problem is Windows or Godot, but I don't have this problem with other programs. What makes you think it's Windows rather than Godot?)

One other thing I noticed: it's complaining about main.scn, which I have to have open in order to save (otherwise it tells me I need to have a root file open) and run the project. I have it open, but I am not touching it at all between saves: I'm purely editing .gd files. Is that behaviour itself maybe part of the problem?

@Zylann
Copy link
Contributor

Zylann commented Mar 19, 2017

I get such errors frequently on Windows 10, even when I don't actually save.

An occurence of it in 3.0 master (here when running the game):
image

@Toshiwoz
Copy link
Contributor

Toshiwoz commented Apr 5, 2017

I have this problem to, aslo with the 2.1.3 RC1, can't tell but, can it be because I also tried with the 3.0 version compiled by the fixnum guys(http://fixnum.org/godot/)?

I've also noticed that this issue prevents godot from generating scenes preview (or thumb, or preview, dunno hot to call it).

I didn't had this problem since the beginning.

@Toshiwoz
Copy link
Contributor

Same thing withRC2 and now with the fresh new stable release.
Can it be because the project was created using 2 different versions?

@Toshiwoz
Copy link
Contributor

And by the way it is also happening when editing scenes or saving editor config.
image

The, how do yu call it.. debug window? Tells me the error is this:

ERROR: FileAccessWindows::close: Condition ' rename_error ' is true.
   At: drivers\windows\file_access_windows.cpp:130
ERROR: SpatialIndexer::_update_camera: Condition ' !E ' is true.
   At: scene\resources\world.cpp:125

And here is the code it is referring to:

if (!PathFileExistsW(save_path.c_str())) {
#endif
			//creating new file
			rename_error = _wrename((save_path + ".tmp").c_str(), save_path.c_str()) != 0;
		} else {
			//atomic replace for existing file
			rename_error = !ReplaceFileW(save_path.c_str(), (save_path + ".tmp").c_str(), NULL, 2 | 4, NULL, NULL);
		}

Can it be that the .tmp files instead of being renamed are copied and then when it tries to create again the .tmp file it fails? (sorry I am going to sleep, don't have enough time to look into that deeper)

@reduz
Copy link
Member

reduz commented Apr 15, 2017 via email

@reduz
Copy link
Member

reduz commented Apr 15, 2017 via email

@Toshiwoz
Copy link
Contributor

No entiendo, I'm using godot only, no text editor.
The function ReplaceFileW does a replace. So as far as I understand it takes, for example, the editor_settings.tres doing a copy of it as a .tmp file, and up to that it works fine, then it tries to replace the content of the original file with the .tmp one, and here I think is where it fails.
To me it's probable that it's godot itself not releasing handle of the files when it should. Or that function has some wrong parameters.

@reduz
Copy link
Member

reduz commented Apr 15, 2017 via email

@Calinou Calinou added this to the 4.0 milestone Mar 30, 2020
@Calinou
Copy link
Member

Calinou commented Mar 30, 2020

@WolfGangsta Does the situation improve if you add the Godot executable to the list of executables ignored by Windows Defender? Alternatively, try adding Documents and %APPDATA% to the list of folders ignored by Windows Defender.

@WolfGangsta
Copy link

Unfortunately, no. The same error messages are generated on starting the Project Manager as before:

ERROR: create: Cannot create cache directory!
   At: editor/editor_settings.cpp:863
ERROR: save: Cannot save EditorSettings config, no valid path
   At: editor/editor_settings.cpp:1052

Trying to open a test project file directly from File Explorer:

ERROR: make_dir_recursive: Method failed. Returning: err
   At: core/os/dir_access.cpp:175
ERROR: Error attempting to create data dir: C:/Users/owend/AppData/Roaming/Godot/app_userdata/Test.
   At: core/os/os.cpp:469
ERROR: create: Cannot create cache directory!
   At: editor/editor_settings.cpp:863
ERROR: save: Cannot save EditorSettings config, no valid path
   At: editor/editor_settings.cpp:1052
ERROR: Cannot create file 'C:\Users\owend\AppData\Roaming/Godot/projects/filesystem_cache6'. Check user write permissions.
   At: editor/editor_file_system.cpp:328
ERROR: Cannot save editor settings to file 'C:\Users\owend\AppData\Roaming/Godot/projects/project_metadata.cfg'.
   At: editor/editor_settings.cpp:1242
ERROR: Couldn't save project.godot - C:/Users/owend/OneDrive/Documents/Godot/Test/project.godot.
   At: core/project_settings.cpp:748
ERROR: Couldn't save project.godot - C:/Users/owend/OneDrive/Documents/Godot/Test/project.godot.
   At: core/project_settings.cpp:748
ERROR: Can't save PNG at path: 'C:\Users\owend\AppData\Local\Temp/Godot/resthumb-ee8051cd8a1d26651c8235db2deadf73.png'.
   At: drivers/png/resource_saver_png.cpp:58
ERROR: Can't save PNG at path: 'C:\Users\owend\AppData\Local\Temp/Godot/resthumb-ee8051cd8a1d26651c8235db2deadf73_small.png'.
   At: drivers/png/resource_saver_png.cpp:58
ERROR: Cannot create file 'C:\Users\owend\AppData\Local\Temp/Godot/resthumb-ee8051cd8a1d26651c8235db2deadf73.txt'. Check user write permissions.
   At: editor/editor_resource_preview.cpp:205
ERROR: Can't save PNG at path: 'C:\Users\owend\AppData\Local\Temp/Godot/resthumb-f4592acc6461da18772508b7db1bfb78.png'.
   At: drivers/png/resource_saver_png.cpp:58
ERROR: Cannot create file 'C:\Users\owend\AppData\Local\Temp/Godot/resthumb-f4592acc6461da18772508b7db1bfb78.txt'. Check user write permissions.
   At: editor/editor_resource_preview.cpp:205

@eon-s
Copy link
Contributor

eon-s commented Apr 5, 2020

@WolfGangsta try using the editor from a non-common folder (not on user directories or program files) and use the self-contained mode, that way you will see the editor data folder created next to the editor executable, if you do not have problems running the editor that way, then windows is blocking the editor for some reason (untrusted downloaded executable or something like that).

@WolfGangsta
Copy link

Aha! I created a new "Godot Editor" folder in the root C: directory and stuck the executable there. Editing, saving, etc. works now, and I didn't have to use self-contained mode. The editor's data remains happily in my user's AppData folder. Thanks for the help!

It does seem a little hacky, though--as a Windows user, I'd expect to find the program in Program Files or some other common directory. I never saw any general recommendation on where to put the .exe, which is why I experimented with putting it in different places to start with. Maybe the issue is that we need more documentation on the subject of Windows "installation"?

@Calinou
Copy link
Member

Calinou commented Apr 6, 2020

It does seem a little hacky, though--as a Windows user, I'd expect to find the program in Program Files or some other common directory.

If you want to install a program user-wide in a standard location, create a folder in %LOCALAPPDATA%, place the executable there and create a start menu shortcut pointing to the executable. Program Files is read-only for unprivileged users and is intended to be used for system-wide installations only.

Maybe the issue is that we need more documentation on the subject of Windows "installation"?

See #8057. Note that the Godot community is quite attached to the concept of not having to install Godot, so installers will be completely optional if they're ever released.

PS: You may be interested in Scoop 🙂

# After installing Scoop, run this in a command prompt:
scoop bucket add extras
scoop install godot

@eon-s
Copy link
Contributor

eon-s commented Apr 6, 2020

Windows package managers like Scoop are getting popular among devs, Godot is on Chocolatey too.

choco install godot

@WolfGangsta
Copy link

Gotcha. Thanks for the help! (And sorry for the late reply.)

I'll look into Scoop and Chocolatey--they look like just what I need to simplify things.

@Calinou Calinou changed the title Saving on Windows succeeds but shows error message dialog Saving on Windows succeeds but shows error message dialog (due to file locking limitations) May 31, 2020
@Calinou
Copy link
Member

Calinou commented Oct 4, 2020

To any of you experiencing this issue, does disabling Filesystem > On Save > Save Safe On Backup Then Rename in the Editor Settings improve the situaton?

@Proksimas
Copy link

Okay guys idk if this may help you but i tried to OC my processor so i installed 2 logiciel to monitoring my core:
Intel Burn
Cinebench from the store.
After my OC i go on godot and i had the same error of you (the lacking permission)
I uninstalled both software and that s work correctly.
So maybe if you have a sofware who use some of tools on windows godot don't like this

@theblooopz
Copy link

To any of you experiencing this issue, does disabling Filesystem > On Save > Save Safe On Backup Then Rename in the Editor Settings improve the situaton?

Turning this off avoids the issue it seems.

@Straighten-Your-Back
Copy link

To any of you experiencing this issue, does disabling Filesystem > On Save > Save Safe On Backup Then Rename in the Editor Settings improve the situaton?

it doesn't improve the situation, it just changes it

with this setting enabled i get the standard "unable to write to file" error

with this setting disabled i instead get the delightfully unhelpful error "alert! error while saving" with absolutely no other information at all.

in either case, the save is successful - i'm just hassled by an error.

this isn't some minor annoyance: this has already caused alarm fatigue. now that i know saves are successful despite this error, i completely ignore these
cannot save.zip
errors, which means i sometimes lose changes because it was actually unable to write. and i can't differentiate until i force quit and restart.

@akien-mga
Copy link
Member

Which Godot version are you using? This might actually be fixed in 3.3.3.

@Straighten-Your-Back
Copy link

Which Godot version are you using? This might actually be fixed in 3.3.3.

my bad, i was using 3.3.2 - i just updated and you're right, the latest version has fixed this issue. thanks for pointing that out.

@Calinou
Copy link
Member

Calinou commented Sep 30, 2021

This should be fixed in 3.3.3 thanks to #51430, closing. Please comment if you can still reproduce this on 3.3.3 or later.

@Calinou Calinou closed this as completed Sep 30, 2021
@Calinou Calinou modified the milestones: 4.0, 3.3 Sep 30, 2021
@akien-mga akien-mga modified the milestones: 3.3, 3.4 Sep 30, 2021
@Syndog
Copy link

Syndog commented Nov 9, 2021

Still happening in version 3.4
a169915cf9c18e9be395b539e65c47da
.

@Calinou
Copy link
Member

Calinou commented Nov 9, 2021

Still happening in version 3.4

If you can only reproduce this in a Mono-enabled build, then it's a different issue.

@fbrier
Copy link

fbrier commented May 4, 2022

Is there an issue#/link for this occurring with a Mono-enabled build? Just want to figure out why I am seeing it in a 3.4-stable Mono build.

@Calinou
Copy link
Member

Calinou commented May 4, 2022

Is there an issue#/link for this occurring with a Mono-enabled build? Just want to figure out why I am seeing it in a 3.4-stable Mono build.

I can't see any open issue about this, so please create a new issue with a minimal reproduction project attached.

@fbrier
Copy link

fbrier commented May 4, 2022

I installed the latest stable non-Mono Godot and it had the same issue. My current guess is this is a misleading error message because the project is in an abnormal state. I am trying to create a GDNative plugin. Along the way, the DLL name changed, so the .gdns file would not load. In the IDE, I deleted it in the IDE, but it looks like it did not delete the references. So then it complained that the scene had a missing reference, and I tried to use the Fix Problems, but the IDE does not appear to have a way of removing the dependency. Then you get this message. So I started over with a fresh Godot project. Thank you. Sorry about the post, but I was trying to figure out what the problem was, and thought this issue was mine.

@steelx
Copy link

steelx commented Oct 9, 2022

Same here. But thanks to Below comment. I was able to fix this.

Windows package managers like Scoop are getting popular among devs, Godot is on Chocolatey too.

choco install godot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests