commercialhaskell / commercialhaskell/stack
build --file-watch triggers rebuild on "Open" events
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
### General summary/comments (optional)
I use `nano` to open a `stack.yaml` (or any watched file e.g. `README.md`) and before everything, a build triggers.
### Steps to reproduce
1. Run `stack build --file-watch` in one window.
2. Run `nano stack.yaml`
### Expected
File opens in editor while stack is sitting idle.
### Actual
File opens in editor while stack is running a build pass where nothing changed yet.
### Stack version
```
$ stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
```
### Method of installation
* Official binary, downloaded from stackage.org or fpcomplete's package repository
### Extra information
Relevant strace bits
```
openat(AT_FDCWD, "/home/username/src/projectname/stack.yaml", O_RDONLY) = 3
fcntl(3, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(3, {st_mode=S_IFREG|0644, st_size=2208, ...}) = 0
read(3, "# This file was automatically ge"..., 4096) = 2208
read(3, "", 4096) = 0
close(3) = 0
```
Events known to INotify:
https://hackage.haskell.org/package/hinotify-0.4/docs/System-INotify.html
I think the problem is hfsnotify files `Open` and `Closed{wasWritable=True}` events under its `Unknown` and stack has to no direct way of opting out of them:
https://github.com/haskell-fswatch/hfsnotify/blob/3dbdf6d902664e8407415314d8304263e6ad112f/src/System/FSNotify/Linux.hs#L63
Contributor guide
Assessment
This issue has not been assessed yet.