flatbuffers
flatbuffers copied to clipboard
Bazel build rules require npm
After upgrading to v23.5.26, projects importing flatbuffers via Bazel fail if @npm
repo isn't present, even if the TS rules aren't in use.
WORKSPACE rule:
http_archive(
name = "com_github_google_flatbuffers",
sha256 = "1cce06b17cddd896b6d73cc047e36a254fb8df4d7ea18a46acf16c4c0cd3f3f3",
strip_prefix = "flatbuffers-23.5.26",
urls = ["https://github.com/google/flatbuffers/archive/refs/tags/v23.5.26.tar.gz"],
)
Build command: bazel build -c opt @com_github_google_flatbuffers//:flatbuffers
Error:
ERROR: Skipping '@com_github_google_flatbuffers//:flatbuffers': error loading package '@com_github_google_flatbuffers//': Unable to find package for @npm//:defs.bzl: The repository '@npm' could not be resolved: Repository '@npm' is not defined.
WARNING: Target pattern parsing failed.
ERROR: error loading package '@com_github_google_flatbuffers//': Unable to find package for @npm//:defs.bzl: The repository '@npm' could not be resolved: Repository '@npm' is not defined.
INFO: Elapsed time: 0.023s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
currently loading: @com_github_google_flatbuffers//
This seems to be a regression as of https://github.com/google/flatbuffers/pull/7928
@philsc thoughts?
Good callout. Not sure how easy it'll be to fix. Will take a look tomorrow.
This looks to be fixable. It requires me to fix a few things I overlooked in the original patch. WIP branch here: https://github.com/philsc/flatbuffers/tree/unreviewed/phil/fix-7988
I just ran into this, it would be nice to have fixed! As a workaround, this very simple patch seems to work if you're only interested in building flatc/cc library:
--- BUILD.bazel
+++ BUILD.bazel
@@ -1,2 +0,0 @@
-load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
-load("@npm//:defs.bzl", "npm_link_all_packages")
@@ -9,7 +6,0 @@
-)
-
-npm_link_all_packages(name = "node_modules")
-
-npm_link_package(
- name = "node_modules/flatbuffers",
- src = "//ts:flatbuffers",
I did fix this via #7990, but as per #8019 it might be a while before it gets merged.
@philsc Hello, any updates on this?
The PR is still open. @dbaileychess , is it something you can (and have time to) look at?
Bumping this as I do see recent PR being merged.
@dbaileychess , any chance you have time to review #7990 ?