facebook / buck2

Build system, successor to Buck
https://buck2.build/
Apache License 2.0
3.55k stars 218 forks source link

buck tracks files it shouldn't in a version control directory (sapling) #57

Closed thoughtpolice closed 1 year ago

thoughtpolice commented 1 year ago

I'm using Sapling with buck. And if I do

buck build ...
sl
buck build ...

The second buck build normally gives me something like:

File changed: root//src/hello/main.rs
File changed: root//.sl/runlog/3513vs2Gf9m4S2DA.lock
File changed: root//.sl/runlog/.tmpeqcGcc
939 additional file changes
...

because sl needs to talk with its daemon and do other things under the .sl/ directory.

This even goes further than that: if Sapling is in the middle of something like a rebase, it may make copies of .bzl files underneath .sl/ during that time, which then get picked up as part of the default cell for the project. This is really annoying. I've had several sl rebase commands fail due to conflicts, and then buck build ... picks up temporary files under .sl/ that are kept as a backup. So if something like a TARGETS file gets copied, buck build ... will fail in some spectacular and unpredictable fashion.

As a short quick fix, it would be nice if whatever logic exists for .git and buck-out to be ignored could be extended to a few other directories, like .sl/ and .hg/

In the long run, it might be nice to have something like a buckignore file for more "exotic" cases like this.

thoughtpolice commented 1 year ago

Oh, there is a setting for this; in the root .buckconfig:

[project]
ignore=.git,.sl,.jj

Took me a minute to find that; should have looked at the Buck 1 site (it's occasionally come in handy still.) Closing this as it can be solved easily.

ndmitchell commented 1 year ago

If you are using the watchman file watcher (not the default in open source) you are encouraged to add it to the watchman ignore, as it will generate less events. In 87ab0b6ffb7ff78e1eebd9cab34b6ca73e9b2f52 I made it so that we implicitly ignore buck-out. I wonder if .git etc should be defaults too?

thoughtpolice commented 1 year ago

Yeah, seeing that commit was the impetus for investigating the .sl directory and this whole issue. There are some pretty reasonable and unambiguous things to ignore: .git, .sl, .jj (for jujutsu) are three obvious ones I'm using. Something like node_modules would also be good.

There's also whether or not something should be ignored recursively by default. node_modules would probably qualify, but unfortunately Cargo's target subdirectory is a bit more of an open question since it's so ambiguous.

Can I ask how watchman integration is supposed to work? Do I need to launch it myself on the repo root, first? I actually got the Ubuntu 22.04 binary working yesterday, but hadn't yet dug into the source to figure out the integration.

thoughtpolice commented 1 year ago

Found that out too: put the following in .buckconfig

[buck2]
file_watcher=watchman

then start a watchman daemon somewhere above the source dir, and set WATCHMAN_SOCK to the socket file appropriately. Seems to be working and ignoring cargo files now!

ndmitchell commented 1 year ago

I think having an initialisation command generate a ignore makes a lot of sense, but I worry about defaulting to things like node_modules without explicit user direction, as otherwise you can potentially accidentally ignore someones code, and then it gets real confusing.

The idea for watchman is if the binary exists it should just work, and it did for me on Windows. But from your remarks elsewhere, sounds like you probably know more than I do by now :)