watchman does not template and write the com.github.facebook.watchman.plist file in the LaunchAgents folder

Created on 6 Aug 2016  Â·  5Comments  Â·  Source: facebook/watchman

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

  • The folder is indeed there, as well as other .plist files from other applications
  • yes I have done every 'permissions fix' posted, (references #69)
  • as well as verified all permissions with disk utility.
  • restarting the computer/terminal/etc computer seemed to magically fix a lot of users, but not me. I have tried all manner and combination of restarts and reinstalls.
  • running brew info watchman shows the application is (supposedly) properly installed
AwesomeProject: 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.

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

All 5 comments

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:

  1. The permissions on /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.
  2. If you have reimaged and restored your system from a backup, there are often invisible ACLs associated with that path and its contents. The resolution that works for most of our users is to remove the file manually. (https://github.com/facebook/watchman/issues/69#issuecomment-117226485)

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yangzhichina picture yangzhichina  Â·  5Comments

joseluisq picture joseluisq  Â·  7Comments

fuechter picture fuechter  Â·  3Comments

ACoolmanBigHealth picture ACoolmanBigHealth  Â·  4Comments

export-mike picture export-mike  Â·  4Comments