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

Flycheck temporary files cause spurious rebuilds #508

Closed
doolio opened this issue Apr 18, 2020 · 13 comments
Closed

Flycheck temporary files cause spurious rebuilds #508

doolio opened this issue Apr 18, 2020 · 13 comments

Comments

@doolio
Copy link

doolio commented Apr 18, 2020

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.

@doolio doolio added the support label Apr 18, 2020
@raxod502
Copy link
Member

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.

@doolio
Copy link
Author

doolio commented May 3, 2020

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.

@raxod502
Copy link
Member

raxod502 commented May 7, 2020

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

@doolio
Copy link
Author

doolio commented May 8, 2020

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/

@raxod502
Copy link
Member

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.

@doolio
Copy link
Author

doolio commented May 10, 2020

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.

@raxod502
Copy link
Member

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?

@raxod502 raxod502 changed the title Visiting a file in a straight repo without making any changes causes package to be rebuilt on next startup Flycheck temporary files cause spurious rebuilds May 12, 2020
@raxod502
Copy link
Member

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

@doolio
Copy link
Author

doolio commented May 12, 2020

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).

@andersjohansson
Copy link
Contributor

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

raxod502 added a commit that referenced this issue May 16, 2020
To use, (setq straight-fix-flycheck t) before loading straight.el.
@raxod502
Copy link
Member

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

@doolio
Copy link
Author

doolio commented May 16, 2020

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.

@andersjohansson
Copy link
Contributor

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

ahyatt pushed a commit to ahyatt/straight.el that referenced this issue Oct 17, 2020
To use, (setq straight-fix-flycheck t) before loading straight.el.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment