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
Support fallback of buck2.file_watcher to 'notify' if 'watchman' doesn't work? #59
Comments
I can probably try to write a patch for this too, if it's deemed acceptable and easy to review/integrate; I don't know how difficult it is to "back-port" changes from GH into the Meta repository in this manner, so if it's harder than just making the change on all of y'alls end, I can wait. |
I don’t think an unconditional fallback would be desirable (it’s certainly
not something we’d ever want to do internally, so merging that would be
undesirable), but allowing e.g. a comma separated list of file watchers to
try, or a separate config value that means « watchman if available but
inotify otherwise » seems like it’d be reasonable (the former seems like
it’d be preferable to me).
Submitting a PR is fine, it’d quite easy to pull in, but bear in mind a
good portion of the team is on holiday, so it might take a little while to
get back to you if you do.
…On Thu, 22 Dec 2022 at 17:27, Austin Seipp ***@***.***> wrote:
I can probably try to write a patch for this too, if it's deemed
acceptable and easy to review/integrate; I don't know how difficult it is
to "back-port" changes from GH into the Meta repository in this manner, so
if it's harder than just making the change on all of y'alls end, I can wait.
—
Reply to this email directly, view it on GitHub
<#59 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANIHVXIYVGTK24QVRMFGJ3WOR6QJANCNFSM6AAAAAATG4IRZM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
We do have https://github.com/facebookincubator/buck2/blob/main/CONTRIBUTING.md, but I've just revised that and put up an internal diff to make it also read:
TLDR: We welcome PRs, and they are actually remarkably easy to merge (if we are around, but as of now, I think almost no one is!) If you want to make your repo plug and play, using inotify is probably fine. Watchman is really useful if you have a huge repo, or are using a Sapling-backed virtual disk. If not, then inotify works great. That's the reason we pick inotify as the default for open source - to increase plug and play ability. |
I tried implementing this over the holiday break but got stuck. I initially tried a naive approach where configuration is parsed, here. Basically: split on But that failed. I think what's happening in this code is that the I'll post my initial attempt later but needless to say I'd still quite like this. As a workaround, at the moment I simply hardcode |
Generally the file watcher lives in the daemon, so I wouldn't expect much to happen in the client (broadly speaking, the client is just a argument parser and output console). When you say fail, do you mean with a panic or with a Alternatively, if Watchman provided binaries for aarch64-linux, would that solve the problem? Should be easy to reach out to that team. Separately, I am curious why you want to default to watchman at all? Wouldn't notify be sufficient? For really big repos, especially ones backed by Sapling/Mercurial, Watchman is a great idea. Otherwise, I imagine notify is good enough. |
So, following up on this: I got on a phone call with Neil a while back and explained that one use case for watchman was integration with Sapling's virtual filesystem, which I intend to explore once it's stable and in a FOSS release. That's a major motivation for integrating watchman reliably and early on. And recently, after a miraculous amount of work from the Nixpkgs community, a recent change added an up-to-date watchman binary, as well as all the dependencies -- and it works on So my need for this feature has basically gone away. Nixpkgs can provide aarch64-linux binaries for my users instead. I also made an upstream issue about this, so non-Nix users can also have binary builds; see facebook/watchman#1094 — but it remains unresolved, due to a lack of appropriate aarch64 builders for GitHub Actions. We'll have to wait until GitHub deploys Ampere builders at some point, I guess... Closing this for now to reduce issue clutter and because the original (niche) motivation has gone away. |
As I noted in #57 (comment), I found a way to enable watchman support via the config option
buck2.file_watcher
. See this corresponding commit, in particular the highlighted lines: thoughtpolice/buck2-nix@e47fc8f#diff-d33e979799a45c7c51752e9c8d96a3e452015d1a40b1e4b6ec6a98e92c4d8430R92-R105 — I also recommend the commit message for a summary.It's very handy. In short, I use direnv to automatically use
systemd-run --user
to launch a transient user service for watchman, then export an appropriateWATCHMAN_SOCK
variable for the repository. Works great! Except...I forgot to enable it in CI, which caused this failure:
So there's two things going on here:
watchman
binary from the repository, the Ubuntu 22.04 one. But I didn't install it withdpkg
, I installed it with Nix, since you can't rely on the user having it. A consequence of this is that some directories, such as/usr/local/var/run/watchman/
, don't exist, which cause spurious failures, since watchman binaries implicitly have aSTATEDIR
set to/usr/local
at build time. And if there is noWATCHMAN_SOCK
variable set, thewatchman_client
Rust library will query the CLI. Therefore calls likewatchman get-sock
or whatever will fail, because they always probe a non-existent statedir which causes part of the stack trace. I can work around this in some way with Nix, and will file a possible bug report with upstream watchman about it; but I just wanted to clarify this since it's in the above error.statefile
,logfile
, andpidfile
, which are the 3 required variables that watchman needs; if these are set, the implicitSTATEDIR
is not used.WATCHMAN_SOCK
instead with my setup, because if it is set, thewatchman_client
library uses it above all else, and doesn't need to query the CLI binary. So it "just works"Would it be possible to optionally fallback to
buck2.file_watcher=notify
ifwatchman_client
detects and captures a failure like above? This would at least allow users to continuing developing in the repository without a strange error if they don't enablewatchman
, even if they would detect file changes watchman would otherwise ignore. I'm trying to make my repository 'plug and play', and it feels bad if youcd $src; buck build ...
and it immediately fails like this without watchman.The text was updated successfully, but these errors were encountered: