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

General questions regarding the usage of CodeLite
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post 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 ?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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
Make sure you have read the HOW TO POST thread
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post by eranif »

Jarod42 wrote:Happy that the bug was identified and reported.
It was not reported ;) I caught it in the action :D

Eran
Make sure you have read the HOW TO POST thread
Post Reply