Skip to content

Bazel sporadically emits warning aboud importlib being modified externally - tends to break automated builds #3643

@oakad

Description

@oakad

Bazel v9.0.0
rules_python v1.8.5
Debian 14 "forky", dockerized

During some invocations of bazel run the following warning is emitted occasionally:

WARNING: Repository '@@rules_python++python+python_3_11_x86_64-unknown-linux-gnu' will be fetched again since the file 'lib/python3.11/importlib' has been modified externally. External modifications can lead to incorrect builds.

Such sporadic warnings may not seem like much, but they wreck havoc in situations where output of bazel run command is precisely scripted. Such situation arise quite commonly in automated builds.

Some additional details:

  1. These are containerized builds, so filesystem state is reset after each build.
  2. The warning does not appear to result from immediate use of any rules_python rules. In my build I invoke two bazel run commands one after another. The first one runs the script which invokes some python rules indirectly via pkg_tar (from rules_pkg) rule. The second one runs a binary which has no python dependencies in its dep tree whatsoever. Only this second invocation sometimes triggers the totally unexpected warning. The binary is not specific - whatever other binary I run via bazel run may or may not trigger the warning.
  3. I wonder if there's a way to somehow initialize the importlib thingy with a separate bazel command so that import commands don't emit any warnings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions