Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error loading package '': Every .bzl file must have a corresponding package, but '@npm//:install_bazel_dependencies.bzl' does not have one

I am working on integrating Bazel into an Angular application. But when running ibazel run //src:devserver I get those errors:

iBazel [8:08AM]: Error getting Bazel info exit status 2
iBazel [8:08AM]: Querying for files to watch...
Loading: 0 packages loaded
ERROR: error loading package '': Every .bzl file must have a corresponding package, but '@npm//:install_bazel_dependencies.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.
Loading: 0 packages loaded
Loading: 0 packages loaded
iBazel [8:08AM]: Bazel query failed: exit status 7
Loading: 0 packages loaded
ERROR: error loading package '': Every .bzl file must have a corresponding package, but '@npm//:install_bazel_dependencies.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.
Loading: 0 packages loaded
Loading: 0 packages loaded
iBazel [8:08AM]: Bazel query failed: exit status 7
iBazel [8:08AM]: Running //src:devserver
Loading: 0 packages loaded
ERROR: error loading package '': Every .bzl file must have a corresponding package, but '@npm//:install_bazel_dependencies.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.
Loading: 0 packages loaded
Loading: 0 packages loaded
iBazel [8:08AM]: Error running Bazel exit status 7

It seems to me as if this is an issue with

lodd("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()

in my WORKSPACE file:

workspace(
    name = "examples_angular",
    managed_directories = {"@npm": ["node_modules"]},
)

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "2eca5b934dee47b5ff304f502ae187c40ec4e33e12bcbce872a2eeb786e23269",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/1.4.1/rules_nodejs-1.4.1.tar.gz"],
)

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")

yarn_install(
    name = "npm",
    package_json = "//:package.json",
    yarn_lock = "//:yarn.lock",
)

load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")

install_bazel_dependencies()

load("@npm_bazel_protractor//:package.bzl", "npm_bazel_protractor_dependencies")

npm_bazel_protractor_dependencies()

load("@npm_bazel_karma//:package.bzl", "npm_bazel_karma_dependencies")

npm_bazel_karma_dependencies()

load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")

web_test_repositories()

load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.2.bzl", "browser_repositories")

browser_repositories(
    chromium = True,
    firefox = True,
)

load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

So what can I do about it?


The devserver target inside my BUILD file:

ts_devserver(
    name = "devserver",
    additional_root_paths = ["src/example"],
    entry_module = "examples_angular/src/main.dev",
    scripts = [
        "@npm//:node_modules/tslib/tslib.js",
        ":rxjs_umd_modules",
        "@npm//date-fns:date-fns.umd.js",
    ],
    static_files = _ASSETS + [
        ":inject_scripts_for_dev",
        "//src/assets",
    ],
    deps = ["//src"],
)

You can reproduce the error by cloning: https://github.com/flolu/cents-ideas/tree/3ad56108507ee77f0b8a072e9c204c32d5c9ebdc and running ibazel run //src:devserver in ./services/angular

like image 839
Flo Avatar asked Mar 09 '20 07:03

Flo


1 Answers

Just checked out your repo and this command works good for me.

Maybe try doing bazel clean --expunge and repeat after that.

like image 181
Ray Avatar answered Sep 20 '22 11:09

Ray