Straight.el: Flycheck temporary files cause spurious rebuilds

Created on 18 Apr 2020  路  13Comments  路  Source: raxod502/straight.el

I've noticed an odd observation where, when I visit a file in a straight repo without making any changes the package is rebuilt on the next startup of Emacs. I understood from the README that packages are only rebuilt when changes are made to the local repository. Is this a bug or a misconfiguration on my part?

The only customisations I've made to straight are as follows:

 '(straight-process-buffer " *straight-process*")
 '(straight-profiles (quote ((nil . "../../pkg-versions.el"))))
 '(straight-use-package-by-default t)

Thanks for your time.

bug conflict confusing behavior eager modification detection filesystem watcher flycheck modification detection mtime

Most helpful comment

Please test with latest commit. See added docs for how to use.

All 13 comments

What is the value of straight-check-for-modifications in your configuration? Do you have anything in your configuration that might cause files to be created, deleted, or modified when you visit a file (such as auto-save, lockfiles, etc.)? If so then that would of course cause straight.el to think there was a modification because the directory mtime will be updated.

Sorry for the late reply.

straight-check-for-modifications is at the default value of (find-at-startup find-when-checking). Well, if I'm not mistaken doesn't Emacs by default create auto-save files. I haven't changed this behaviour but I assumed such files were only created when the file is edited and not simply visited. Similarly, I've not changed the default setting for create-lockfiles which is set to t. Should I?

I do configure several settings related to backup files (e.g. backup-by-copy, delete-old-versions, version-control all set to t - though vc-make-backup-files is set to the default value of nil) but again assumed such files are only created when a file is edited but perhaps I'm wrong in my assumption. Would this explain what I've observed?

Thanks for your time.

Your assumptions seem reasonable. Why don't you check *straight-process* to see what files straight.el thinks are modified?

Why don't you check straight-process to see what files straight.el thinks are modified?

Ok, so after the find command I see the last repo directory that I visit. For this test case, it is:

/home/doolio/.emacs.d/straight/repos/org-gtd.el/

but not the file I visit namely org-gtd.el. If I visit more than one straight repo before restarting Emacs it will list the different repos as so but again not the file itself:
/home/doolio/.emacs.d/straight/repos/org-gtd.el/ /home/doolio/.emacs.d/straight/repos/no-littering/

Okay, so I guess it must be a temporary file then. Try running

$ watchexec 'env | grep WATCHEXEC'

in the repository directory, then do whatever triggers a rebuild. watchexec should print out all the paths of files that are modified in the directory, which could tell us what is responsible for the temporary file.

Okay, watchexec prints the following. I presume it is listed in reverse order as in the last message is the top message i.e. the temporay flycheck file is created, written to and then removed which is I guess is why git doesn't detect it.

WATCHEXEC_REMOVED_PATH=/home/doolio/dotfiles/emacs/dot-emacs.d/straight/repos/org-gtd.el/flycheck_org-gtd.el
WATCHEXEC_WRITTEN_PATH=/home/doolio/dotfiles/emacs/dot-emacs.d/straight/repos/org-gtd.el/flycheck_org-gtd.el
WATCHEXEC_CREATED_PATH=/home/doolio/dotfiles/emacs/dot-emacs.d/straight/repos/org-gtd.el/flycheck_org-gtd.el

Perhaps I'm seeing something similar to #519 as it too mentions temporary files created by flycheck. Thanks for your time.

Ah. I forgot that Flycheck did this. I have long since disabled Flycheck for Elisp files because the line number reporting is so bad, so I never ran into this problem. Do you think we should try to disable Flycheck for Elisp files by default when the filesystem watcher is enabled in straight.el?

Or wait, not just when using the filesystem watcher, I guess in general when using any kind of modification detection for straight.el.

Yes, when using any kind of modification detection would be best. I was not using watchexec before you suggested it. Also, I don't use flymake but does it too create these temporary files and if so it too may cause the same behaviour? (I've been meaning to try it as I've read it has greatly improved of late).

Current workaround for me: Disable flycheck, enable flymake :slightly_smiling_face: . I mostly code elisp and flymake seems to do quite a good job there.

Please test with latest commit. See added docs for how to use.

Excellent. This works for me. I no longer see the spurious builds when visiting a straight repo file. Modifying a file I visit in a straight repo on the other hand results in a rebuild as expected. Thanks for the quick turnaround. This issue can be closed from my point of view.

Thanks for a smart workaround! It seems reasonable to assume that we won鈥檛 need flychecks extensive checks for unchanged files in our repositories, they should (ideally) be in a good state.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aspiers picture aspiers  路  4Comments

dertuxmalwieder picture dertuxmalwieder  路  3Comments

agsdot picture agsdot  路  4Comments

aspiers picture aspiers  路  4Comments

progfolio picture progfolio  路  3Comments