-
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
cant build with bazel and ccache #12124
Comments
My guess is that bazel sandboxing is blocking access. If that is the case, try building with Your workaround using |
It is usually useful to run bazel with |
here you go |
as of |
Your reasoning makes sense. I just personally prefer one bold try with Sandboxing can be switched off, or you may try less powerfull sandbox, by doing either Previous instances of similar issues I was able to find were due to sandboxing
edit: in any case, you've attached the verbose log. That should be enough information for somebody more knowledgeable about bazel to figure things out. You could maybe add the command you use to run bazel, and how you tell it to use ccache, as further information. |
BTW, bazel has a background daemon. It is sometimes useful to kill it and restart it, because it might be remembering some now out-of-date state, with |
Dont get it, am I the only one who have a problem with sandboxing? it is quite fresh machine, 3 or 4 weeks, I remember having the same problem with previous machine with Ubuntu 18.04. Mystery... |
In that case, what does using the sandbox writable path argument, that is |
worked too |
Awesome. That's expected behavior. Sandboxing limits the writable paths the build can write into. If you want ccache to work from inside a Bazel build with sandboxing turned on, you have to add $HOME/.ccache to the write allowlist. This is how the other Bazel+ccache issues I found turned out, too. One thing I don't understand is why sudo also ended up, in effect, disabling the sandbox. |
then it is odd the problem is not easily searchable on the net, since it sounds as something quite usual. |
You can create config file |
It looks like this is a documentation request at this point, to clarify that users should pass --sandbox_writeable_path to enable ccache with sandboxing. Does that sound right to you? |
Whatever discoverable by google search will do, I guess |
I do have problems with that solution. If I add EDIT: sorry, not even adding it to the |
in bazel.rc should work. What does not work is using env variables, such as |
Thanks, I think I forgot the build... |
I get that whitelisting this .ccache path works, but this is still pretty surprising behaviour to have by default. We're trying to roll-out bazel usage for engineers at cockroachdb/cockroach, and it's unfortunate to have to ask each person include this (custom, because of $USERNAME) path in their local .bazelrc.user or something. Fundamentally though, I'm not sure why bazel is relying on the ccache-wrapped compiler doing it's own caching when bazel is perfectly capable of caching the generated artifacts. Is there any benefit I'm no seeing? Very naively, if bazel always exported CCACHE_DISABLE=1, to disable any sort of compiler-initiated caching (with artifacts placed outside the sandbox!), that'd be more in-line with what I'd expect. I think it's also more "bazel"-like, since this external write is clearly unexpected. Perhaps even surfacing this as a "--disable-ccache" option could work, though I'd still push for this to be the default. All that said, I'm glad to have found this issue -- would've spent many more hours on cockroachdb/cockroach#66988 if I hadn't. |
The workarounds I've seen elsewhere (RobotLocomotion/drake#4464, RobotLocomotion/drake#5130) feel a tad-bit unfortunate. It's similar to what we're thinking of in cockroachdb/dev#11, and feels more appropriate to fix up-stream. Curious to hear your thoughts. |
Please don't make disabling the thing the user tried to do the default. The Bazel cache is not something shared between build systems, whereas ccache is. It would be great if Bazel worked better with ccache though, and especially if the known issues were documented (currently the top result is a stackoverflow answer, which isn't the worst) |
Discovered this issue building https://github.com/ankitects/anki on my Fedora 36 system. The command I invoked was:
and ccache complains it cannot locate gcc on the path, which is somewhat amusing. The workaround for me was to explicitly define
This feels like surprisingly brittle behaviour. |
On Fedora 36 I get
whether I use the sandbox option or not, installed from npm or binary. |
Me too. |
@createyourpersonalaccount I have the same problem now, also on Fedora 36. Trying to build for example this target in bazel itself
I can fix this by making the cache directory accessible from sandbox, by adding the appropriate parameter (as discussed in the previous comments on this issue), covering all the paths that the build desires write access to
(If I did not create .ccache directory beforehand, I'd get IO error about the directory not existing) |
Description of the problem / feature request:
Bazel fails to build
tcmalloc
with messageBugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I guess no special steps needed.
ccache
works fine, I'm able to build without usingsudo
with CMake, for exampleWhat operating system are you running Bazel on?
Ubuntu 20.04
What's the output of
bazel info release
?release 3.5.0
Have you found anything relevant by searching the web?
semi-related
#1540
but I installed the Bazel using
apt
Any other information, logs, or outputs that you want to share?
worked as expected once I ran Bazel under
sudo
, but I guess it is not the expected behaviorlet me know if you need any additional information
The text was updated successfully, but these errors were encountered: