Watchman does not template and write the com.github.facebook.watchman.plist file in the LaunchAgents folder, when installed via homebrew.
When I was running watchman watch <filename> I was getting a permission error related to Users/<myname>/Library/LaunchAgents/com.github.facebook.watchman.plist 'Permission denied"
eg:
016-08-05T23:29:31,391: [cli] Failed to open /Users/<username>/Library/LaunchAgents/com.github.facebook.watchman.plist for write: Permission denied
when I tried all the things mentioned throughout the issues and forums, it became apparent the file _wasnt there_.
so I looked - on line 436 of main.c in (the file that templates and writes the .plist file). It simply doesn't actually write the file, and doesn't throw an error during installation via brew install watchman and or brew install --HEAD watchman
so jsut to assist in troubleshooting
brew info watchman shows the application is (supposedly) properly installedAwesomeProject: brew info watchman
watchman: stable 4.6.0 (bottled), HEAD
Watch files and take action when they change
https://github.com/facebook/watchman
/usr/local/Cellar/watchman/HEAD-bbd5957 (26 files, 453.0K) *
Built from source on 2016-08-05 at 23:05:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/watchman.rb
==> Dependencies
Build: autoconf ✔, automake ✔
Required: pcre ✔
As far as I can see, the permissions are fine (at least for LaunchAgents) - but the file isn't there.
I should add I am not a watchman 'pro'. This is my first time working with it, and I'm stopped dead in my tracks. If I've overlooked something _obvious_ let me know. Thanks for your time.
Note that due to the slightly unusual architecture of watchman, the launchd configuration is managed just-in-time per user rather than centrally at installation time. The root cause of this problem is unlikely to be related to homebrew itself.
There are 2 probable causes for this type of problem:
/Users/<username>/Library/LaunchAgents do not allow writing any files for your user. Can you try the simplistic touch /Users/<username>/Library/LaunchAgents/TESTING to check that the permissions are basically correct? Please also share the output from ls -ld /Users/<username>/Library/LaunchAgents.If nothing obvious stands out, please collect some more debugging information together so that we can review it.
https://github.com/facebook/watchman/issues/90 has an example of a similar issue, and a user collected this gist https://gist.github.com/kellyjandrews/394097ae8786e2a352a1 that was very helpful to understand the state on the system and lead directly to a resolution for them.
Ok I'll return to this when I can.
I'll say some good news - I managed to get it working. you're gonna laugh, but here was the fix - I built the file on another machine (my laptop), opened it - looked inside and checked to see if anythign needed to be changed (yep, XML). Then I copied it to my problem machine (in this case a desktop) watchman did work after that.
So good news - I'm not stuck. Bad news - that's kind of a hacky work-around indeed, and not useful to you as a maintainer.
Thanks for responding so quickly, btw.
TL;DR - made the file somewhere else. Put it where it should be. Things worked.
This makes me think that it was some invisible filesystem context thing (similar to the restored-from-backup, or machine migration case).
I'm going to speculatively close this out because I think that you're not going to be able to reproduce the problem now that you've found a solution, and that you likely have other things to do with your time.
Thanks for reporting this; the additional information, even if somewhat anecdotal, helps improve our picture on what is going on here.
no problem, glad i could help - and i totally agree its best to close. thanks again for your time and attention
I just ran into this issue with a fresh install of Watchman via Homebrew. In my case it was caused by ~/Library/LaunchAgents being owned by root. So the solution was simply sudo chown <username> ~/Library/LaunchAgents and it worked like a charm. You can change the directory ownership back to root after the plist file is written without any side effects. If anyone else is having the same problem do give it a try.
Most helpful comment
I just ran into this issue with a fresh install of Watchman via Homebrew. In my case it was caused by
~/Library/LaunchAgentsbeing owned by root. So the solution was simplysudo chown <username> ~/Library/LaunchAgentsand it worked like a charm. You can change the directory ownership back to root after the plist file is written without any side effects. If anyone else is having the same problem do give it a try.