You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bazel can overwrite __init__.py with empty file in source tree #2947
If I mess up my BUILD structure, and forget to include srcs = ["__init__.py"], it seems it can happen that Bazel overwrites the existing __init__.py with an empty file.
Right now this looks like a duplicate of #2945, could you please explain how this is different, I don't fully understand the word "overwrite" here. Does it replace data inside the source tree?
If you add common --incompatible_default_to_explicit_init_py to your .bazelrc, it disables this behaviour. You'll now be responsible for creating your own init files though!
I'm witnessing this even when my __init__.py is declared in my srcs= super odd. Using bazel 8.4.2
Anyone else also witnessed that? About to try that flat in .bazelrc to see if the problem goes away. In my case it seems to happen only on bazel testfailures
Activity
aignas commentedon May 31, 2025
Right now this looks like a duplicate of #2945, could you please explain how this is different, I don't fully understand the word "overwrite" here. Does it replace data inside the source tree?
tholenst commentedon May 31, 2025
Yes, it deletes data inside the source tree.
tholenst commentedon May 31, 2025
This bug is about bazel deleting my code. #2945 is about a cleanup.
SandyChapman commentedon Nov 28, 2025
If you add
common --incompatible_default_to_explicit_init_pyto your .bazelrc, it disables this behaviour. You'll now be responsible for creating your own init files though!https://bazel.build/reference/command-line-reference#flag--incompatible_default_to_explicit_init_py
Vinh-CHUC commentedon Jan 26, 2026
I'm witnessing this even when my
__init__.pyis declared in mysrcs=super odd. Usingbazel8.4.2Anyone else also witnessed that? About to try that flat in
.bazelrcto see if the problem goes away. In my case it seems to happen only onbazel testfailures