-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Every .bzl file must have a corresponding package, but X does not have one #12630
Comments
This happens to me just about every time I fetch new stuff from the repository at this point. |
Oops it looks like I didn't finish filling out the issue report. I am now running |
@GMNGeoffrey I got this issue recently. I found there are 2 ways for fixing it.
|
Thanks. That then brings us to bazelbuild/buildtools#923 😁 I also find I get this with rules_python |
Now also getting this with
We use this in our WORKSPACE file and do load it normally, I think, so maybe this isn't just a rules_cc thing? |
Just add the And I think it is how bazel works indeed. If you don't add What do you think ? |
Hmmm what you describe has been my experience with other And testing it out, the Bazel skylib release archive does have different behavior here. I believe it does something fancy to avoid the need for the gcmn@lt 2021-01-07 16:56 ~/Downloads/bazel-extract-test$ mv ../bazel-toolchains-3.3.1.tar.gz ./
gcmn@lt 2021-01-07 16:56 ~/Downloads/bazel-extract-test$ tar -xzf bazel-toolchains-3.3.1.tar.gz
gcmn@lt 2021-01-07 16:56 ~/Downloads/bazel-extract-test$ ls
bazel-toolchains-3.3.1 bazel-toolchains-3.3.1.tar.gz
gcmn@lt 2021-01-07 16:56 ~/Downloads/bazel-extract-test$ rm -rf *
gcmn@lt 2021-01-07 16:57 ~/Downloads/bazel-extract-test$ mv ../bazel-skylib-1.0.2.tar.gz
mv: missing destination file operand after '../bazel-skylib-1.0.2.tar.gz'
Try 'mv --help' for more information.
gcmn@lt 2021-01-07 16:57 ~/Downloads/bazel-extract-test$ mv ../bazel-skylib-1.0.2.tar.gz ./
gcmn@lt 2021-01-07 16:57 ~/Downloads/bazel-extract-test$ tar -xzf bazel-skylib-1.0.2.tar.gz
gcmn@lt 2021-01-07 16:57 ~/Downloads/bazel-extract-test$ ls
bazel-skylib-1.0.2.tar.gz bzl_library.bzl CONTRIBUTORS internal_setup.bzl lib.bzl rules toolchains workspace.bzl
BUILD CODEOWNERS internal_deps.bzl lib LICENSE skylark_library.bzl version.bzl So note that the archive structure for bazel_skylib doesn't have the nesting |
Running clean multiple times a day... I'll just drop this quote from the Bazel docs
https://docs.bazel.build/versions/master/user-manual.html#the-clean-command P3 👀 |
Sounds like a correctness issue, why was this classified as P3 in the first place? @jin @oquenchil It doesn't seem to have a lot to do with C++ though, it's more like an issue with either the Starlark loading phase machinery or the external repositories. @GMNGeoffrey , it'll be hard to fix this without a reproduction that works at least some of the time. Mind coming up with something that reproduces the issue at least sometimes? |
@philwo , the external repository machinery is more likely to be the culprit than Starlark because otherwise we'd se regular reports of this in google3, so assigning this to you for further routing (or a clever idea) |
@Wyverald Could you have a look at this? |
@GMNGeoffrey Could you provide some repro steps? Running what Bazel command gives you the error message? I tried to clone the llvm-bazel repo and build it according to the Usage section, but only got the following error immediately:
|
@Wyverald looks like you didn't init submodules ( |
Ok further details: This happens to me with both https://github.com/google/iree and https://github.com/google/llvm-bazel. These repositories use different versions of Bazel: 3.3.1 and 3.7.1. Fetching new commits does not appear to be the proximate cause, as I had originally guessed. Rather it seems to happen whenever the Bazel server starts up again. The error is not for a consistent package (like rules_cc). Here is the one I saw most recently:
My home
which is another common factor between these issues. I generally build with rbe however and our rbe config sets Is there some kind of archive I can package up to help demonstrate the issue? I made an archive of my entire git repository (happy to share in whatever manner, though it's 1.8G), which is currently experiencing the issue. If I extract that on the same computer, the error repeats, but if I copy it to another computer running the same OS, the build works fine (the path I copy it to and various other factors are the same across these two machines, so I think symlinks and such just happen to line up). If I then package up and do the same with the outputBase directory, I can get the same behavior on another machine. In fact the archive of the source isn't necessary, so it's some kind of corruption in the output base. |
I tried building llvm-bazel, shutting down the Bazel server after that, and then re-building llvm-bazel again, and nothing has gone wrong yet so far. But as you said the problem doesn't always happen after a server restart, so I'll try a rebuild every now and then to see if I can catch a repro. What's your RBE setup? Maybe that could be related? Also could you go into |
Yeah I also haven't been able to repro by just manually shutting down the server. Maybe something with idle server shutdown? It seems to happen the first time I go to build for the day (which was why I thought it had to do with syncing, since I usually do that). The RBE setup is in the .bazelrc and WORKSPACE. It's basically just the default setup with rbe_autoconfig. IREE has basically the same setup. Looking in gcmn@ws 2021-04-08 10:47 ~/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/bazel_skylib$ ls
lib rules toolchains WORKSPACE There's also no file called workspace.bzl though... so that's confusing. Is this the kind of sneaky auto loading thing? If I go into the same directory on a machine without the issue (I think nothing machine-specific, I just happen to have two computers accessible to me): gcmn@ct 2021-04-08 10:51 ~/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46-bak/external/bazel_skylib$ ls
BUILD CODEOWNERS internal_deps.bzl lib LICENSE skylark_library.bzl version.bzl workspace.bzl
bzl_library.bzl CONTRIBUTORS internal_setup.bzl lib.bzl rules toolchains WORKSPACE So yeah for some reason those files aren't showing up. Seems like an issue with repo rules? |
Same issue with rules_cc: gcmn@ws 2021-04-08 10:52 ~/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/rules_cc$ ls
cc distro examples third_party tools WORKSPACE vs gcmn@ct 2021-04-08 10:52 ~/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46-bak/external/rules_cc$ ls
BUILD CODEOWNERS distro internal_deps.bzl ISSUE_TEMPLATE.md README.md third_party WORKSPACE
cc CONTRIBUTING.md examples internal_setup.bzl LICENSE renovate.json tools And then if I gcmn@ws 2021-04-08 10:55 ~/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46$ ls external/bazel_skylib/
BUILD CODEOWNERS internal_deps.bzl lib LICENSE skylark_library.bzl version.bzl workspace.bzl
bzl_library.bzl CONTRIBUTORS internal_setup.bzl lib.bzl rules toolchains WORKSPACE
gcmn@ws 2021-04-08 10:55 ~/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46$ ls external/rules_cc/
BUILD CODEOWNERS distro internal_deps.bzl ISSUE_TEMPLATE.md README.md third_party WORKSPACE
cc CONTRIBUTING.md examples internal_setup.bzl LICENSE renovate.json tools The directories are correctly populated. So... something is deleting those files? I'm poking around looking for linux utilities to tattle on a process that deletes a file. |
Ok so more details. I tried following https://askubuntu.com/questions/48844/how-to-find-the-pid-of-the-process-which-has-deleted-a-file to audit the deletion of that file, but couldn't get it to work. In the meantime, manually deleting |
Ok I think I've set up an auditd rule to watch for deleting of bazel_skylib, so we'll see how that goes. |
Realized I never answered this question. Any bazel build/test of the repository basically. Simplest is just |
Oh no... I think I know the problem... and it's my fault... 🤦
Bazel kept on using up all of my disk space, so I figured I could empty out old cache entries. It's called "cache" so surely it must be ok to delete things from a correctness perspective. Apparently that's not true 😁 But also $ ll $HOME/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/bazel_skylib/BUILD
-r--r--r-- 1 gcmn primarygroup 1591 Dec 31 1999 /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/1655d0ec87ba8569e84422cbb0aeec46/external/bazel_skylib/BUILD that doesn't seem right? So I did a bad thing for sure and this is my fault. I think there are some Bazel issues here that lead me to do this, in retrospect obviously bad, thing
So deleted that cron job for now. I would love to come up with a safe replacement before Bazel fills up my drive again. FTR I think I never would've figured this out without the suggestion of where to look for a BUILD file. The error about '@bazel_skylib//:workspace.bzl' gave me nothing. It's not any of the symlinks that are created in the source directory, which I did explore. Also lol at all my guesses as to why I was seeing this "daily" and what that could correlate with. Turns out it just correlated with... days... |
I don't think Bazel (or any software) can be resilient to deleting various data files from under it. I am somewhat surprised about Bazel using hundreds of gigabytes of storage. It should create exactly one directory directly under If you want to clean up old entries under |
I wanted to add to a few points:
That's true. You can nuke the entire cache directory and Bazel will still work fine. You can even nuke some subdirectories under there (for example ~/.cache/_bazel_gcmn/<some_hash>). But I don't think it's fair to expect Bazel to keep working when random files are deleted in the cache folder.
If you mean the mtime being in 1999 doesn't seem right, that's on bazel_skylib's packaging. If you download the tar.gz and unpack it yourself, you'll see that all the files in there have the same mtime. |
The mtimes are that old for reasons of hermeticity; we don't want the exact time used for the build to influence its outputs so we stub out the timestamps. |
Thanks @Wyverald for asking the critical question that made it possible for me to figure out what was going on here:
This was key :-)
Agreed. I misunderstood which things were safe to delete. Sorry about that!
I'm going to try not cleaning things up for a little bit and see what starts filling up. I think it was some combination of these caches and the bazel disk cache, and it's possible that while I was in there I decided to try to clean up both. So in some ways this is linked to #1035. Bazel seems to be missing a pretty important secondary feature of caches: cache eviction. It's an example of the way in which it carries its legacy of being a remote-mostly tool for developers at a big tech company with tons of resources. I'm using a top of the line workstation and still running into issues, so it's not surprising to me when folks with less at their fingertips are reticent to choose Bazel.
Thanks for the tip. If I have to revive this custom cleanup process in another form, I'll use that to make sure it's safer. |
Description of the problem / feature request:
Twice in the last two days when returning to rebuild a Bazel project, I've seen an error about it being unable to find the .bzl file for rules_cc rules. I think this has to do with the implicit loading of rules_cc by Bazel, as you'll notice that nowhere is that file mentioned in the repository (https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/google/llvm-bazel%24+%22cc:defs.bzl%22&patternType=regexp).
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
As this is a non-deterministic thing, it's a bit hard to reproduce. It seems to happen basically every time I fetch new commits in https://github.com/google/iree or https://github.com/google/llvm-bazel
What operating system are you running Bazel on?
Linux Debian
What's the output of
bazel info release
?Happens with Bazel 3.3.1 and 3.7.1
What's the output of
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
?Have you found anything relevant by searching the web?
No
The text was updated successfully, but these errors were encountered: