dune-release icon indicating copy to clipboard operation
dune-release copied to clipboard

dune-release leaves empty files around

Open hannesm opened this issue 2 years ago • 2 comments

I think it would be great if dune-release can be trained to clean up after itself. Sadly, I find lots of empty /tmp/dune-release-*.stderr files around. is there any reason for this?

hannesm avatar Mar 26 '23 19:03 hannesm

Hmm, that's strange, we use Bos.OS.File.tmp: https://github.com/tarides/dune-release/blob/2ca40e3638bf1ec7b0224d5e8e18893be748390a/lib/sos.ml#L106 and according to its documentation

The file is deleted at the end of program execution using a Stdlib.at_exit handler.

So it could be that dune-release crashes somehow so the at_exit handlers aren't called?

However I'm not much of a fan of this approach anyway, so maybe switching to with_tmp_output or with_tmp_oc is a cleaner alternative as the removal happens closer to the code that's creating it.

Leonidas-from-XIV avatar Mar 27 '23 09:03 Leonidas-from-XIV

I could verify with strace that unlink is called correctly and I couldn't reproduce. I would say it's an issue in bos.

maybe switching to with_tmp_output or with_tmp_oc is a cleaner alternative

unfortunately, it's not possible to use the return value of these helpers with ~err, so I think File.tmp is the best we can use with bos.

emillon avatar Apr 21 '23 14:04 emillon