Page 1 of 1

Failed to open file '%filename' for write. Override it ?

Posted: Sat Feb 01, 2014 5:28 pm
by Jarod42
Since I installed CL 5.4, I got sometime this message when trying to save a file (like main.cpp):
Failed to open file '%filename' for write. Override it ?
.

Is there something new which may lock the file in 5.4 ?

Re: Failed to open file '%filename' for write. Override it ?

Posted: Sat Feb 01, 2014 8:47 pm
by eranif
Its a bug in libclang.dll ...
I reported 2 bugs to clang-dev community:

1) libclang.dll fails to clean the .PCH files it generates which is under %TMP% (you will see preamble-*.pch files there). I workaround it in codelite by adding a background thread that cleans the directory and silently ignore any file which is still in use (the thread will only clear files that matches the pattern %TMP%\preamble*.pch)
2) If an clang TU is "alive" and compiled by libclang.dll, any file that it might be including will often still be locked. Again, I tried to workaround it by automatically clear clang's cache before saving the file. This works 90% in the cases.
Here is the link to the bug fix (scroll to LiteEditor/cl_editor.cpp):
https://github.com/eranif/codelite/comm ... bc2ab53b03
I assume that on the second attempt to save the file it works?

This happens only on Windows and only when clang is enabled. You can try and disable it or ignore these annoying messages, usually the second attempt to save the file will work
(before my workarounds, it was impossible to save a file that got locked by clang :P )

Eran

Re: Failed to open file '%filename' for write. Override it ?

Posted: Sat Feb 01, 2014 11:43 pm
by Jarod42
Thanks for the explanation.
Yes it works the second time.
So I will have to work slowly ^_^ to give enough time to unlock file.

Happy that the bug was identified and reported.

Re: Failed to open file '%filename' for write. Override it ?

Posted: Sun Feb 02, 2014 1:53 am
by eranif
Jarod42 wrote:Happy that the bug was identified and reported.
It was not reported ;) I caught it in the action :D

Eran