Skip to content
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

how to build with pre-download external dependencies for offline build? #11123

Closed
lxlmummy opened this issue Apr 14, 2020 · 6 comments
Closed
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: support / not a bug (process) untriaged

Comments

@lxlmummy
Copy link

lxlmummy commented Apr 14, 2020

I just learned to use bazel to build google glog project. My computer network is blocked. I've downloaded glog which gflag dependents to the directory '/home/jamescook/lab/test/new-glog/download/ '.
Now, I run the follow command:
bazel build --distdir=/home/jamescook/lab/test/new-glog/download/ glog
then build error happens,follow is the detail info:

bazel build --distdir=/home/jamescook/lab/test/new-glog/download/ glog
INFO: Call stack for the definition of repository 'com_github_gflags_gflags' which is a http_archive (rule definition at /root/.cache/bazel/_bazel_root/4103e065900cc37ff22791b2ccc18505/external/bazel_tools/tools/build_defs/repo/http.bzl:296:16):

/home/jamescook/lab/test/new-glog/glog-0.4.0/WORKSPACE:3:1
WARNING: Download from https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz failed: class java.net.ConnectException Network is unreachable (connect failed)
WARNING: Download from https://github.com/gflags/gflags/archive/v2.2.2.tar.gz failed: class java.net.ConnectException Network is unreachable (connect failed)
ERROR: An error occurred during the fetch of repository 'com_github_gflags_gflags':
java.io.IOException: Error downloading [https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz, https://github.com/gflags/gflags/archive/v2.2.2.tar.gz] to /root/.cache/bazel/_bazel_root/4103e065900cc37ff22791b2ccc18505/external/com_github_gflags_gflags/v2.2.2.tar.gz: Network is unreachable (connect failed)
ERROR: /home/jamescook/lab/test/new-glog/glog-0.4.0/BUILD:5:1: //:glog depends on @com_github_gflags_gflags//:gflags in repository @com_github_gflags_gflags which failed to fetch. no such package '@com_github_gflags_gflags//': java.io.IOException: Error downloading [https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz, https://github.com/gflags/gflags/archive/v2.2.2.tar.gz] to /root/.cache/bazel/_bazel_root/4103e065900cc37ff22791b2ccc18505/external/com_github_gflags_gflags/v2.2.2.tar.gz: Network is unreachable (connect failed)
ERROR: Analysis of target '//:glog' failed; build aborted: no such package '@com_github_gflags_gflags//': java.io.IOException: Error downloading [https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz, https://github.com/gflags/gflags/archive/v2.2.2.tar.gz] to /root/.cache/bazel/_bazel_root/4103e065900cc37ff22791b2ccc18505/external/com_github_gflags_gflags/v2.2.2.tar.gz: Network is unreachable (connect failed)
INFO: Elapsed time: 25.645s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

My question is whether bazel's distdir option didn't work or whether I used it incorrectly.

If I used it wrong, how should I change it?

@lxlmummy lxlmummy changed the title how to build with Pre-download external dependencies for offline build? how to build with pre-download external dependencies for offline build? Apr 14, 2020
@jin
Copy link
Member

jin commented Apr 17, 2020

Did you place these unreachable files in /home/jamescook/lab/test/new-glog/download/ separately? Distdir works by reaching into the specified directory for the required files, instead of connecting to the internet for them.

@jin jin added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged labels Apr 17, 2020
@lxlmummy
Copy link
Author

Yes, I downloaded the dependency package glog in advance ,in /home/jamescook/lab/test/new-glog/download/. Can you give me an example of how to use the Distdir option correctly?I can't find it in bazel's official guide and that will help me a lot.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@djamaile
Copy link

Did you manage find the right command?

@lxlmummy
Copy link
Author

lxlmummy commented Nov 2, 2020

Yes, use “--override_repository” option.

@lxlmummy lxlmummy closed this as completed Nov 2, 2020
@shadow-yuan
Copy link

@lxlmummy Did you solve it? I have the same problem as you.

@lxlmummy
Copy link
Author

@shadow-yuan Yes, use “--override_repository” option.

@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: support / not a bug (process) untriaged
Projects
None yet
Development

No branches or pull requests

6 participants