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

Spago run --watch runs(/compiles) twice with vim #346

Closed
googleson78 opened this issue Jul 30, 2019 · 20 comments
Closed

Spago run --watch runs(/compiles) twice with vim #346

googleson78 opened this issue Jul 30, 2019 · 20 comments

Comments

@googleson78
Copy link
Contributor

I'm not sure if this is a bug with spago or something stemming from my setup (I don't have the same issue with stack --file-watch though), so sorry in advance if this is a mistake on my part!

Repro steps:

  1. spago init
  2. spago run --watch
  3. After the initial run, save src/Main.purs (even without modifying it). I use vim to do this step.

Expected behaviour:
Files are compiled and run once.

Observed behaviour:
Files are run (and possibly compiled?) twice.

Sample output after a save:

File changed, rebuilding: "/home/googleson78/git/spago-watch-double-compile-repro/src/Main.purs"
Compiling Main
Build succeeded.
🍝
Success! Waiting for next file change.
Type help for available commands. Press enter to force a rebuild.
Build succeeded.
🍝
Success! Waiting for next file change.
Type help for available commands. Press enter to force a rebuild.

spago version is 0.8.5.0

@klntsky
Copy link
Collaborator

klntsky commented Jul 30, 2019

My neovim does this too. But not nano.
I believe this is related: https://vi.stackexchange.com/questions/11629/set-backupcopy-yes-doesnt-still-writes-the-file-twice

@googleson78 googleson78 changed the title Spago run --watch runs(/compiles) twice Spago run --watch runs(/compiles) twice with vim Jul 30, 2019
@googleson78
Copy link
Contributor Author

googleson78 commented Aug 1, 2019

Thanks @klntsky!

Setting backupcopy=yes resolves this problem, however I am still left wondering what the difference between spago and stacks file change detection is.

@f-f
Copy link
Member

f-f commented Aug 1, 2019

I literally copypasted the implementation from Stack's one, so I'm not sure. I'll take a look

@f-f
Copy link
Member

f-f commented Aug 5, 2019

@googleson78 which OS are you on? (I'm asking because I'm trying to tweak the debounce logic but it doesn't seem to have any effect on macOS)

@googleson78
Copy link
Contributor Author

Linux (Debian testing)

@f-f f-f mentioned this issue Aug 6, 2019
@f-f
Copy link
Member

f-f commented Aug 6, 2019

@googleson78 could you try the branch from #362?

If that doesn't work you could try tweaking the debounce time here

@klntsky
Copy link
Collaborator

klntsky commented Aug 6, 2019

May it be so that debounce settings do not apply if a file was deleted and re-created, just like Vim does?

@klntsky
Copy link
Collaborator

klntsky commented Aug 6, 2019

I tried building from #362 and I still get all File changed, triggering a build messages duplicated when using nvim.

@f-f
Copy link
Member

f-f commented Aug 6, 2019

May it be so that debounce settings do not apply if a file was deleted and re-created, just like Vim does?

Oh right, now it makes sense, thanks. Then I cannot figure out why it's different from Stack's behaviour

@klntsky
Copy link
Collaborator

klntsky commented Aug 6, 2019

Because the code is different (it diverged)

@f-f
Copy link
Member

f-f commented Aug 6, 2019

Yeah, though the changes from the original are limited:

  • I removed the color stuff
  • Generalized from IO to m
  • Wired in our glob stuff
  • Removed this clearing of the dirtiness flag (so you'd get another rebuild if you changed files while the thing was building)

And this last thing might be the reason for this happening, but I still don't understand why

@f-f
Copy link
Member

f-f commented Aug 9, 2019

Update: I tried to apply the last fix I mentioned above, from here, and it didn't help :(
So I'll give up on this, unless someone here has some idea on how to make progress

@klntsky
Copy link
Collaborator

klntsky commented Aug 9, 2019

I think I can give it a try.

@klntsky
Copy link
Collaborator

klntsky commented Aug 10, 2019

I see no way other than re-implementing debouncing.

@klntsky
Copy link
Collaborator

klntsky commented Aug 12, 2019

#371

@f-f
Copy link
Member

f-f commented Aug 16, 2019

The reason why this didn't happen with Stack but it happened with Spago just dawned on me: Stack watches single files, but we match file modification events against globs instead

@klntsky
Copy link
Collaborator

klntsky commented Aug 16, 2019

So what exactly causes doubled event triggering?

@f-f
Copy link
Member

f-f commented Aug 16, 2019

@klntsky I did not verify this but I suspect that if you watch the single file you might get less events

@helinko
Copy link

helinko commented Aug 29, 2019

Nice to see this fixed! Could we get it released soon?

@f-f
Copy link
Member

f-f commented Aug 29, 2019

@helinko yup, I'm going to cut a release in the next days!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants