I'm not sure what's going on here, but it appears that a gflags dependency isn't being found with the docker build rules. Consider this sample project: foo.tar.gz
$ tar -xvzf foo.tar.gz
x foo/
x foo/.bazelrc
x foo/BUILD
x foo/dir/
x foo/foo.py
x foo/WORKSPACE
x foo/dir/file.txt
$ cd foo
$ bazel build :app
INFO: Found 1 target...
ERROR: /private/tmp/foo/BUILD:11:1: DockerLayer app-layer.tar failed (Exit 1).
Traceback (most recent call last):
File "/private/var/tmp/_bazel_hwright/0c1dcd494edf6933a7c645d083d11d41/bazel-sandbox/1744782642231142962/execroot/__main__/bazel-out/host/bin/external/io_bazel_rules_docker/docker/build_tar.runfiles/__main__/../io_bazel_rules_docker/docker/build_tar.py", line 23, in <module>
from third_party.py import gflags
File "/private/var/tmp/_bazel_hwright/0c1dcd494edf6933a7c645d083d11d41/bazel-sandbox/1744782642231142962/execroot/__main__/bazel-out/host/bin/external/io_bazel_rules_docker/docker/build_tar.runfiles/bazel_tools/third_party/py/gflags/__init__.py", line 1, in <module>
from gflags import *
ModuleNotFoundError: No module named 'gflags'
Target //:app failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.379s, Critical Path: 0.17s
$
It would appear that something goofy is happening with the sys.path, so that it isn't finding all the gflags symbols from within the gflags module. This happens at both HEAD and the latest release (0.2.1).
(This is using --force_python=p3 and --python_path=/usr/local/bin/python3, if it matters.)
What version of Bazel are you on? I believe gflags is coming from @bazel_tools, so maybe this moved in 0.6?
I'm running Bazel ~HEAD.
@damienmg Any insight?
Can reproduce python3 is the issue, let see if I can do simpler repro.
I can repro with using pkg_tar, probably linked with how we depends on third_party/ things in Bazel.
In the bazel repo:
$ bazel build --force_python=py3 --python_path=/usr/bin/python3 :bazel-srcs
INFO: Analysed target //:bazel-srcs (0 packages loaded).
INFO: Found 1 target...
ERROR: /usr/local/google/home/dmarting/git/bazel/BUILD:63:1: error executing shell command: 'bazel-out/host/bin/tools/build_defs/pkg/build_tar --flagfile=bazel-out/local-py3-fastbuild/bin/bazel-srcs.args' failed (Exit 1)
Traceback (most recent call last):
File "/usr/local/google/home/dmarting/.cache/bazel/_bazel_dmarting/4c68128ea7d752c9535d956d14249eea/bazel-sandbox/5414131446493874244/execroot/io_bazel/bazel-out/host/bin/tools/build_defs/pkg/build_tar.runfiles/io_bazel/tools/build_defs/pkg/build_tar.py", line 23, in <module>
from third_party.py import gflags
File "/usr/local/google/home/dmarting/.cache/bazel/_bazel_dmarting/4c68128ea7d752c9535d956d14249eea/bazel-sandbox/5414131446493874244/execroot/io_bazel/bazel-out/host/bin/tools/build_defs/pkg/build_tar.runfiles/io_bazel/third_party/py/gflags/__init__.py", line 1, in <module>
from gflags import *
ImportError: No module named 'gflags'
Target //:bazel-srcs failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.721s, Critical Path: 0.83s
FAILED: Build did NOT complete successfully
$ bazel build :bazel-srcs
INFO: Analysed target //:bazel-srcs (0 packages loaded).
INFO: Found 1 target...
Target //:bazel-srcs up-to-date:
bazel-bin/bazel-srcs.tar
INFO: Elapsed time: 0.867s, Critical Path: 0.03s
INFO: Build completed successfully, 2 total actions
Filed the issue on Bazel side.
@damienmg thanks, I'm going to close this one then.
@hwright thanks for all the feedback!
I'll note here that bazelbuild/bazel#3816 is still open, in spite of the proposal in bazelbuild/bazel#3855 to fix it which has been open for almost two months. It would be really nice to see this fixed at some point, but it feels like there's nothing I can do beyond pester folks on the core team. :/
@davidstanke can we get this a little love?
Most helpful comment
@davidstanke can we get this a little love?