Bazel build behind proxy

Viewed 10198

I would like to follow tensorflow example to build generate_streaming_test_wav to generate test wav. And my bazel version is 0.16.1.

The problem is when I use command bazel run tensorflow/examples/speech_commands:generate_streaming_test_wav , the following error message shown up:

xxx@xxx:~/kws/tensorflow-0911$ bazel run tensorflow/examples/speech_commands:generate_streaming_test_wav
Starting local Bazel server and connecting to it...
ERROR: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//closure': Error downloading [https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz, https://github.com/bazelbuild/rules_closure/archive/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz] to /home/janet/.cache/bazel/_bazel_janet/2d14dc1ff5782da202e00efcc3cd86bc/external/io_bazel_rules_closure/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz: All mirrors are down: []
ERROR: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//closure': Error downloading [https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz, https://github.com/bazelbuild/rules_closure/archive/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz] to /home/janet/.cache/bazel/_bazel_janet/2d14dc1ff5782da202e00efcc3cd86bc/external/io_bazel_rules_closure/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz: All mirrors are down: []
INFO: Elapsed time: 57.573s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

However, I can use wget download those two packages. 1.https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz 2.https://github.com/bazelbuild/rules_closure/archive/dbb96841cc0a5fb2664c37822803b06dab20c7d1.tar.gz I think my network should be fine. I have no idea why it can't download those files.

Any idea or suggestions would be very appreciated!

3 Answers

create a folder say 'dist'.

Now whatever URL bazel is not able to download . do wget inside that folder. ( wget normally works with most of proxy)

then run

'bazel build ...... --distdir  dist'

it will take packages from dist and compilation will do start.

If you know your proxy server, you should be able to set:

export HTTPS_PROXY=http://me:mypassword@myproxyserver.domain.com:myport
export HTTP_PROXY=http://me:mypassword@myproxyserver.domain.com:myport

and run the bazel build again.

If you don't know the proxy server used by wget check /etc/wgetrc or ~/.wgetrc

I've seen conflicting statements about HTTPS_PROXY and HTTP_PROXY being uppercase and lowercase, so you might try setting both. (Some have used unset to remove the lowercase settings. See: https://github.com/bazelbuild/bazel/issues/587#issuecomment-412531604)

This might be a bug in Bazel's repository rules. If you'd be so kind to file a bug, that'd be great!

As a workaround, extract the downloaded archive somewhere and replace the io_bazel_rules_closure rule in the WORKSPACE file with a local_repository rule pointing to the directory where you extracted the archive.

Related