I created the following test files for testing bazel build
on Ubuntu
.
The rules are copied from angular:https://github.com/angular/angular
Here is the testing script:
mkdir -p /tmp/testcd /tmp/testcat > BUILD <<EOFload("@build_bazel_rules_nodejs//:index.bzl", "js_library")EOFcat > WORKSPACE <<EOFload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")http_archive( name = "build_bazel_rules_nodejs", sha256 = "5dd1e5dea1322174c57d3ca7b899da381d516220793d0adef3ba03b9d23baa8e", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.3/rules_nodejs-5.8.3.tar.gz"],)EOF
then run:
bazel build
Here is the output:
/tmp/test# which bazel/usr/bin/bazel/tmp/test# bazel --versionbazel 7.0.0/tmp/test# bazel buildExtracting Bazel installation...Starting local Bazel server and connecting to it...WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.WARNING: Usage: bazel build <options> <targets>.Invoke `bazel help build` for full description of usage and options.Your request is correct, but requested an empty set of targets. Nothing will be built.INFO: Found 0 targets...INFO: Elapsed time: 17.390s, Critical Path: 0.03sINFO: 1 process: 1 internal.INFO: Build completed successfully, 1 total action
And then, try to find the http_archive downloaded file from cache:
# find $HOME/.cache/bazel -type f -name '*nodejs*' -exec echo {} \;
But there is nothing in the $HOME/.cache/bazel
.
It seems that bazel
didn't run "load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
", it also didn't run the urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.3/rules_nodejs-5.8.3.tar.gz"]
defined in the "http_archive
".
Here is the expected output:
The "rules_nodejs-5.8.3.tar.gz" and some other dependencies files should exist in the $HOME/.cache/bazel.
How to make bazel
to run "load ...
" and "http_archive ...
" defined in BUILD
and WORKSPACE
?