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

File change watcher is not working in TextMate2 on Mac #1053

Closed
hgfischer opened this issue Apr 6, 2015 · 46 comments
Closed

File change watcher is not working in TextMate2 on Mac #1053

hgfischer opened this issue Apr 6, 2015 · 46 comments
Assignees
Milestone

Comments

@hgfischer
Copy link

File watching in the current master version is broken in Mac, but not on Linux. Hugo looks to detect only the first change. Another sub-sequential changes are not detected.

I also had to checkout the 967d001ebe40cfe90992d953880356a495216202 version instead of the v0.13 tag because the v0.13 cannot be built.

@bep
Copy link
Member

bep commented Apr 6, 2015

I would be very surprised if this was true - as the core Hugo devs are mostly hugging their pretty Macs. I'm Linux.

Can you confirm this @mdhender ?

@mdhender
Copy link
Contributor

mdhender commented Apr 6, 2015

I'm not having any issues with the current master recognizing multiple changes:

$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

$ go build

$ go install

$ hugo version
Hugo Static Site Generator v0.14-DEV BuildDate: 2015-04-06T15:32:57-05:00

$ cd ~/Data/Sites/n608/

$ hugo server -w
0 draft content
0 future content 
2 pages created
0 paginator pages created
0 tags created
0 categories created
in 6 ms
Watching for changes in /Users/test/Data/Sites/n608/{data,content,layouts,static,themes/l}
Serving pages from /Users/test/Data/Sites/n608/public
Web Server is available at http://localhost:1313/
Press Ctrl+C to stop

Change detected, rebuilding site
2015-04-06 15:36 -0500
0 draft content
0 future content 
2 pages created
0 paginator pages created
0 tags created
0 categories created
in 6 ms

Change detected, rebuilding site
2015-04-06 15:36 -0500
0 draft content
0 future content 
2 pages created
0 paginator pages created
0 tags created
0 categories created
in 6 ms

@hgfischer
Copy link
Author

The Mac issue was observed in the computer of @reginaldosousa. Maybe he can give more detail about his Mac.

We tested many times, and got the same behavior even after resetting the entire GOPATH (bin, pkg and src).

@mdhender
Copy link
Contributor

mdhender commented Apr 6, 2015

It looks like there is an outdated dependency for the v0.13 tag.

$ git checkout v0.13
Note: checking out 'v0.13'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at e43eaba... Updating the final release notes for v0.13

$ git status
HEAD detached at v0.13
nothing to commit, working directory clean

$ go get
package bitbucket.org/kardianos/osext
    imports bitbucket.org/kardianos/osext
    imports bitbucket.org/kardianos/osext: code in directory /Users/Guest/go/src/bitbucket.org/kardianos/osext expects import "github.com/kardianos/osext"

$ go build
commands/version.go:23:2: code in directory /Users/Guest/go/src/bitbucket.org/kardianos/osext expects import "github.com/kardianos/osext"

$ go get -u
package github.com/spf13/hugo: github.com/spf13/hugo is a custom import path for https://github.com/spf13/hugo, but /Users/Guest/go/src/github.com/spf13/hugo is checked out from https://github.com/spf13/hugo.git

@mdhender
Copy link
Contributor

mdhender commented Apr 6, 2015

FWIW:

$ uname -a
Darwin Michaels-Mac-Pro.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
$ go version
go version go1.4.2 darwin/amd64

@hgfischer
Copy link
Author

Yes @mdhender. That is why I had to checkout 967d001 to be able to build something that resembles v0.13, which works well in Mac.

@bep
Copy link
Member

bep commented Apr 6, 2015

There are (big) rooms for improvements in the Go packaging world. So, if you build v0.13 now (if it had built successful), you will not get the same binary now compared to when it was released (because third partiy deps have changed).

So I would either:

  1. Use brew (that I now think has the source dependencies sorted out)
  2. Download the binary
  3. Use the latest master

@hgfischer
Copy link
Author

@bep If you start over with a clean GOPATH, are you able to successfully build v0.13?

  1. The current brew formula does exactly what is needed to fix the v0.13 release before building it. It applies a patch to do the same thing that 967d001 does: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/hugo.rb

  2. This is OK, but not feasible in my use case. I have to support more than one platform environment and the go tool should be sufficient to install Hugo without issues.

  3. The latest master appears to have a bug, as was previously reported in this issue.

We should not create other ways to build/install things that are made in Go. The go tooling is sufficient enough for building and installing things. IMHO it is nice to have a Brew formula to install a binary or maybe install Go and use it to build Hugo, but applying a patch just because the v0.13 release got wrong, is a smell for me.

In this case, I suggest creating a v0.13.1 release with the proper fix.

@reginaldosousa
Copy link

$ uname -a
Darwin Mac-81.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
$ go version
go version go1.4.2 darwin/amd64

@bep
Copy link
Member

bep commented Apr 6, 2015

For "bulding from a release tag" to be a success, we need to have a source release process that also includes thirdparty deps. I see discussion about a formal improvements of the current situation at go-nuts/go-dev mailing list, but it's not an easy task and not something that can be solved by Hugo alone.

@spf13 is the man to talk to about releases.

@mdhender
Copy link
Contributor

mdhender commented Apr 7, 2015

I know that "v014-DEV build works on my Mac" isn't the answer that you're looking for, but it does. The only time I've had problems with the watch stopping were when there were errors in the templates. Sometimes the errors cause me to have to restart the server.

@hgfischer
Copy link
Author

Our templates does not have errors, nor warnings. At least Hugo is not complaining. If is there some way to debug this, maybe we (me and @reginaldosousa) could help fix the issue, but we need help to debug it.

@mdhender
Copy link
Contributor

mdhender commented Apr 7, 2015

Can you share the template? I have time this afternoon to run on my Mac to see if I can duplicate the issue. That would be a first step.

@hgfischer
Copy link
Author

It is based on the original Hugo docs template, extracted from it's own source repository.

@tcurdt
Copy link

tcurdt commented May 28, 2015

Installed via homebrew

Hugo Static Site Generator v0.14 BuildDate: 2015-05-26T18:46:46+02:00

and have the same problem.

I am running hugo server -w --theme=html5 --buildDrafts and it does not very consistently respond to file changes.

Especially when changing and saving the same file twice.
It's almost as if it only triggers on the first change per file.

@dunn
Copy link
Contributor

dunn commented May 28, 2015

I can't replicate that on 10.10.3, with Hugo 0.14 also installed via brew.

@tcurdt
Copy link

tcurdt commented May 28, 2015

Odd. I am also on 10.10.3.

@dunn
Copy link
Contributor

dunn commented May 28, 2015

If you run it with --verbose, is there any output after the first reload?

@tcurdt
Copy link

tcurdt commented May 29, 2015

$ hugo server -w --verbose --theme=html5 --buildDrafts
INFO: 2015/05/29 Using config file: /Users/tcurdt/Downloads/hugo-test/config.toml
INFO: 2015/05/29 syncing from /Users/tcurdt/Downloads/hugo-test/themes/html5/static to /Users/tcurdt/Downloads/hugo-test/public/
INFO: 2015/05/29 syncing from /Users/tcurdt/Downloads/hugo-test/static/ to /Users/tcurdt/Downloads/hugo-test/public/
INFO: 2015/05/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
ERROR: 2015/05/29 Site's .BaseUrl is deprecated and will be removed in Hugo 0.15. Use .BaseURL instead.
WARN: 2015/05/29 Unable to locate layout for 404 page: [404.html theme/404.html]
2 of 2 drafts rendered
0 future content 
2 pages created
0 paginator pages created
0 tags created
0 categories created
in 12 ms
Watching for changes in /Users/tcurdt/Downloads/hugo-test/{data,content,layouts,static,themes/html5}
Serving pages from /Users/tcurdt/Downloads/hugo-test/public
Web Server is available at http://127.0.0.1:1313/
Press Ctrl+C to stop

<save /Users/tcurdt/Downloads/hugo-test/content/about.md>
INFO: 2015/05/29 File System Event: ["/Users/tcurdt/Downloads/hugo-test/content/about.md": CHMOD "/Users/tcurdt/Downloads/hugo-test/content/about.md": REMOVE]

Change detected, rebuilding site
2015-05-29 02:56 +0200
INFO: 2015/05/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
WARN: 2015/05/29 Unable to locate layout for 404 page: [404.html theme/404.html]
2 of 2 drafts rendered
0 future content 
2 pages created
0 paginator pages created
0 categories created
0 tags created
in 14 ms

<save /Users/tcurdt/Downloads/hugo-test/content/about.md>
<save /Users/tcurdt/Downloads/hugo-test/content/about.md>
<save /Users/tcurdt/Downloads/hugo-test/content/about.md>

<save /Users/tcurdt/Downloads/hugo-test/content/post/2015-test-test/index.md>
INFO: 2015/05/29 File System Event: ["/Users/tcurdt/Downloads/hugo-test/content/post/2015-test-test/index.md": CHMOD "/Users/tcurdt/Downloads/hugo-test/content/post/2015-test-test/index.md": REMOVE]

Change detected, rebuilding site
2015-05-29 02:59 +0200
INFO: 2015/05/29 found taxonomies: map[string]string{"tag":"tags", "category":"categories"}
WARN: 2015/05/29 Unable to locate layout for 404 page: [404.html theme/404.html]
2 of 2 drafts rendered
0 future content 
2 pages created
0 paginator pages created
0 tags created
0 categories created
in 19 ms

<save /Users/tcurdt/Downloads/hugo-test/content/post/2015-test-test/index.md>
<save /Users/tcurdt/Downloads/hugo-test/content/post/2015-test-test/index.md>
<save /Users/tcurdt/Downloads/hugo-test/content/post/2015-test-test/index.md>

@bep
Copy link
Member

bep commented Jun 28, 2015

@tcurdt are you still having this issue?

The thing is, I'm running OSX now -- and having this exactly issue.

See #1236

@bep bep added the Bug label Jun 28, 2015
@bep bep added this to the v0.15 milestone Jun 28, 2015
@bep bep self-assigned this Jun 28, 2015
@tcurdt
Copy link

tcurdt commented Jun 28, 2015

@bep yupp!

@bep
Copy link
Member

bep commented Jun 28, 2015

The good thing is, I do not give up easily.

I have found a pattern (weird one, but still, a pattern).

  • With hugo server -w
  • If I open up foo.md in TextMate2 (my preferred text editor)
  • Do first change = > Hugo rebuilds, browser reloads OK
  • Do second change => Nothing

I I instead make the changes by just appending to the file:

echo "foo" >> foo.md

I can make many changes and everything works as expected. So it must be something fishy with the events triggered by the repetitive saves in Textmate2.

@tcurdt what text editor do you use?

@bep
Copy link
Member

bep commented Jun 28, 2015

It's also working normally in TextEdit. So TextMate2 is the problem for me.

@dunn
Copy link
Contributor

dunn commented Jun 28, 2015

I can replicate this on TextMate also. It does not happen when I'm using Emacs.

@tcurdt
Copy link

tcurdt commented Jun 28, 2015

@bep Wow - that I didn't expect. Was also using Textmate2 at the time.

@bep
Copy link
Member

bep commented Jun 28, 2015

Yea, looks like it's the Atomic Save feature that messes up live reload stuff (not only for Hugo, but also Grunt etc.) -- I can not find a way to turn it off (it was an option in TextMate 1).

@tcurdt
Copy link

tcurdt commented Jun 30, 2015

Maybe worth filing a bug on the watcher package then.

@tcurdt
Copy link

tcurdt commented Jul 13, 2015

I've now seen this in a js setup as well - which to me suggests a problem on an even lower level.

Super annoying.

@renatovargas
Copy link
Contributor

Hello everyone. I installed Hugo with homebrew and I am also getting the problem where the server with the --watch option tracks only one save with Textmate 2.0-beta.7.4. I'm on a MacBook Air and OS X Yosemite 10.10.4. I could use another text editor, but for me Textmate is very comfortable. Has anyone figured out a straight forward workaround? Thanks to all of you. Wonderful work!

@Kevin-Hamilton
Copy link

I just ran into this as well. Here's some issues from the fsnotify project that are probably related:
https://github.com/go-fsnotify/fsnotify/search?q=atomic&type=Issues

I'm not a Go developer, so I don't know that I can be much help, but here's some links I found in researching this that may be helpful to the Hugo developers:
golang/go#4068
howeyc/fsnotify#54
https://github.com/rjeczalik/notify

@Kevin-Hamilton
Copy link

Hm, I've done some testing with https://github.com/emcrisostomo/fswatch, with https://github.com/shama/gaze (the library behind gulp, grunt, etc), and with https://github.com/paulmillr/chokidar (the library behind browserify, webpack, etc) and all of them seem be succeeding at capturing multiple consecutive Textmate 2 saves. So I'm going to try and wire together a workaround to hugo server -w using one of these aforementioned projects until the underlying issue gets solved in hugo.

Maybe hugo could suggest a workaround like one of these in the docs, until a hugo fix surfaces...

@bep
Copy link
Member

bep commented Aug 24, 2015

We will when a workaround arrives.

@renatovargas
Copy link
Contributor

Thanks Kevin.

@jbshirk
Copy link

jbshirk commented Jan 10, 2016

I thought you'd like to know that this issue affects me when I use Brackets. It might detect the first change after a restart but doesn't after that. However, switching to TextSoap watch works fine.

HTH

@mikekreuzer
Copy link

I get no updates at all with Atom 1.3.2/1.33. With TextEdit updates happen as I type, with Coda updates happen on file saves. Hugo v0.15 via brew.

@bep
Copy link
Member

bep commented Jan 10, 2016

I have done some tests with TextMate andfsnotify`.

  • An edit triggers the events CHMOD + REMOVE
  • I guess the REMOVE triggers an un-watch in fsnotify

This hack-of-the-year works in my simple tests:

if event.Op&fsnotify.Remove == fsnotify.Remove {
    err = watcher.Add(event.Name)
    if err != nil {
        log.Fatal(err)
    }
}

@nathany - any input/advice on a temporary workaround for Hugo? This bug bugs me ...

/cc @spf13 @anthonyfok

@bep
Copy link
Member

bep commented Jan 10, 2016

I have done some more testing and created a workaround-PR, see #1766

bep added a commit to bep/hugo that referenced this issue Jan 10, 2016
An edit in `TextMate` on OS X triggers the events `CHMOD` and `REMOVE`.

This makes `fsnotify` stop watching that file.

This commit works around that problem by re-adding the file to the watcher on `REMOVE` if the file still exists.
See gohugoio#1053
@bep
Copy link
Member

bep commented Jan 10, 2016

I thought you'd like to know that this issue affects me when I use Brackets.

@jbshirk just tested Brackets (nice editor) on OS X -- and it works fine for me re. watching (even without my patch).

@bep
Copy link
Member

bep commented Jan 10, 2016

This patch in fsnotify fixes it for me in TextMate:

https://github.com/go-fsnotify/fsnotify/pull/111

@nathany
Copy link
Contributor

nathany commented Jan 14, 2016

Thanks @bep. https://github.com/go-fsnotify/fsnotify/pull/111 is merged.

Those waiting for this fix can update fsnotify and rebuild Hugo.

go get -u gopkg.in/fsnotify.v1 

@bep bep closed this as completed Jan 14, 2016
@jbshirk
Copy link

jbshirk commented Jan 14, 2016

@bep Yes, it turned out to be a complex of issues, not the least was google drive interfering with normal finder functioning. Now brackets seems to be working the best of all the others I've tried.

@WallStProg
Copy link

It seems that this is still an issue w/version 2.0-rc.4.

@github-actions
Copy link

github-actions bot commented Mar 4, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests