【发布时间】:2020-11-01 01:17:27
【问题描述】:
我想用 Bazel 构建我的 jsonnet。为此,我正在使用 jsonnet 规则。不幸的是,在我的构建管道中,我无法从 github 中提取。因此,我一直在阅读离线版本,但似乎找不到可行的解决方案。我已经提取了 jsonnet 规则 repo 并尝试使用
构建 jsonnet$ bazel test //project ----distdir=<jsonnet_rules_repo>
但这不起作用。所以,我想知道是否有人知道处理这个问题的正确方法?
更新:
这是错误信息
> ERROR: An error occurred during the fetch of repository 'jsonnet_go':
Traceback (most recent call last):
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git.bzl", line 177, column 30, in _git_repository_implementation
update = _clone_or_update(ctx)
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git.bzl", line 36, column 20, in _clone_or_update
git_ = git_repo(ctx, directory)
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 91, column 12, in git_repo
_update(ctx, git_repo)
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 103, column 10, in _update
fetch(ctx, git_repo)
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 129, column 27, in fetch
_git_maybe_shallow(
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 171, column 15, in _git_maybe_shallow
_error(ctx.name, start + args_list, st.stderr)
File "/private/var/tmp/_bazel/9246e2215e1e698b5691dcd295e999fc/external/bazel_tools/tools/build_defs/repo/git_worker.bzl", line 182, column 9, in _error
fail("error running '%s' while working with @%s:\n%s" % (command_text, name, stderr))
Error in fail: error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @jsonnet_go:
fatal: unable to access 'https://github.com/google/go-jsonnet/': Could not resolve host: github.com
ERROR: no such package '@jsonnet_go//bazel': error running 'git fetch origin refs/heads/*:refs/remotes/origin/* refs/tags/*:refs/tags/*' while working with @jsonnet_go:
fatal: unable to access 'https://github.com/google/go-jsonnet/': Could not resolve host: github.com
我也将 jsonnet repo 放在 distdir 文件夹中,但仍然出现此错误。
【问题讨论】:
-
你在
--distdir目录中放了什么?您是否在WORKSPACE中指定了它的内容?确实如此,bazel 文档 (docs.bazel.build/versions/master/external.html#offline-builds) 严重不足,但他们确实指出了他们如何为 bazel 发行版本身做到这一点:github.com/bazelbuild/bazel/blob/… -
@JayEye 我将所有 jsonnet 规则都放在 dist 目录中。但是 jsonnet 规则也加载到包中,但是没有加载到 dist 目录中。不知道下一步该做什么。