facebook / watchman

Watches files and records, or triggers actions, when they change.
https://facebook.github.io/watchman/
MIT License
12.57k stars 986 forks source link

Trivial watchman-replicate-subscription usage #1041

Open pinko-fowle opened 2 years ago

pinko-fowle commented 2 years ago

Hello. Watchman has been quite hard to start with. There's no documentation for getting going quickly as a developer, seeing what's happening. It took a couple hours of reading the docs & playing around on the command line, but I feel like this ought to work:

$ watchman watch-project $(pwd) --no-local
{
    "version": "2022.07.04.00",
    "watch": "/Users/pinko-fowle/src/my-project",
    "watcher": "fsevents"
}

$ watchman watch-list
{
    "version": "2022.07.04.00",
    "roots": [
        "/Users/pinko-fowle/src/my-project"
    ]
}

$ watchman-replicate-subscription $(pwd) --list
No matching subscriptions

$ watchman-replicate-subscription $(pwd)
Error, no matching subscriptions:
    criteria: (name='Any', pid='Any' client='Any')
    path: /Users/pinko-fowle/src/my-project
To get a list of subscriptions for a watched root, use:
    watchman-replicate-subscription PATH --list

After the above, I can also see:

ps -aef|grep watchman
  503 79722     1   0  2:57PM ??         0:00.72 /opt/homebrew/bin/watchman --foreground --logfile=/opt/homebrew/var/run/watchman/pinko-fowle-state/log --log-level=1 --sockname=/opt/homebrew/var/run/watchman/pinko-fowle-state/sock --statefile=/opt/homebrew/var/run/watchman/pinko-fowle-state/state --pidfile=/opt/homebrew/var/run/watchman/pinko-fowle-state/pid

Alas, watchman-replicate-subscription -p 79722pwd--list $(pwd) doesn't work any better than the above attempts.

I don't know how to begin to debug this or figure out what's wrong with this. I'd really love if there was some kind of quick cheatsheet or tutorial for watching watchman in use. I've written my own node-js client and can use this project there acceptably, but the command line interface remains incredibly forboding & that lack of first-use-cli-user-experience very much keeps me from ever consider trying to drive broader adoption of this wonderful tool that I love & can code. Also, what am I doing wrong?

Afaik watchman-replicate-subscription is the only cli tool available that will helpfully show you what is happening without having to go build a json query. (Edit: oohh this is probably the error... I still have to make a subscription don't I? Trying.) This is a huge first step. I've tried searching online for watchman-replicate-subscription, but see very few results.

pinko-fowle commented 2 years ago

I had to create a subscription & open a persistent client via cat mysub.json | watchman -j -p. This shows me the subscription actively. And I can run watchman-replicate-subscription on it.