facebook / watchman

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

Allow state directory based in `$HOME`. #1236

Open carlocab opened 3 months ago

carlocab commented 3 months ago

The reasoning for this is already outlined well in #1092.

This would be useful for us in Homebrew, and would probably limit the number of bug reports you get from Homebrew users that get tripped up by our hard-coded WATCHMAN_STATE_DIR. (See, e.g., #963.)

It should also reduce the number of users who end up with brew building Watchman from source because they're using a non-default prefix, and hopefully issues from them too (e.g. #1132).

Closes #1092.

facebook-github-bot commented 3 months ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 3 months ago

@carlocab has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot commented 3 months ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

carlocab commented 3 months ago

CC @andrewhamon for thoughts, since you might be interested.

genevievehelsel commented 2 months ago

hi @carlocab - this looks like a nice change to have, thanks for the PR! Would you mind sharing some manual test output/examples to verify the behavior and that it works?

Also, instead of gating this at build time in the CMake file, could we put this behind a watchmanconfig (and default it to off)? https://facebook.github.io/watchman/docs/config

carlocab commented 2 months ago

Thanks for having a look!

Would you mind sharing some manual test output/examples to verify the behavior and that it works?

Sure, here you go:

Test command output ``` ❯ _build/bin/watchman; echo $? 0 ❯ _build/bin/watchman get-sockname { "sockname": "/Users/carlocab/.local/state/watchman/carlocab-state/sock", "version": "20240803.002435.0", "unix_domain": "/Users/carlocab/.local/state/watchman/carlocab-state/sock" } ❯ _build/bin/watchman watch . { "version": "20240803.002435.0", "watcher": "fsevents", "watch": "/Users/carlocab/github/watchman" } ❯ _build/bin/watchman watch-list { "version": "20240803.002435.0", "roots": [ "/Users/carlocab/github/watchman" ] } ❯ _build/bin/watchman shutdown-server { "version": "20240803.002435.0", "shutdown-server": true } ```

Let me know if there are any other commands you'd like me to try.

Also, instead of gating this at build time in the CMake file, could we put this behind a watchmanconfig (and default it to off)? facebook.github.io/watchman/docs/config

Sure, this makes sense to me. Does an option like use_xdg_state_dir or similar sound ok?