bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Error reporting: help users understand they are missing a transitive WORKSPACE dep

Open alexeagle opened this issue 8 years ago • 3 comments

In rules_typescript and rules_nodejs we are increasingly picking up transitive dependencies on more workspaces. This makes the upgrade path very confusing for our users.

For example, today I got this report:

Hey so I just rebased to master for rules_nodejs and now im getting this error for the examples/program tests

fabian@fabian-desktop:~/Documents/rules_nodejs/examples/program$ bazel test :test
ERROR: Failed to load Skylark extension '@bazel_skylib//:lib.bzl'.
It usually happens when the repository is not defined prior to being used.
Maybe repository 'bazel_skylib' was defined later in your WORKSPACE file?
ERROR: cycles detected during target parsing

The last line talks about cycles detected, which is extra scary, and it suggests maybe an ordering problem. It doesn't say anything about the most common case which is that you just don't have this workspace dependency declared at all. Also it doesn't say where the load statement was.

I think a better error would look like

ERROR: Failed to load dependency '@bazel_skylib'.
Loaded from @build_bazel_rules_nodejs//internal:node_repositories.bzl line 6

Bazel does not automatically include repositories which are transitively required.
You must fetch the 'bazel_skylib' repository with a statement like `http_archive` in your WORKSPACE file.
This may also happen when the repository is not defined prior to being used.
Maybe repository 'bazel_skylib' was defined later in your WORKSPACE file?

alexeagle avatar Jul 27 '18 22:07 alexeagle

@alexeagle I have the same problem. Can you write out how you solved this. I am using https://github.com/bazelbuild/rules_docker#nodejs_image

elrapha avatar Sep 10 '18 12:09 elrapha

Figured out i had to include external dependencies like so

http_archive( name = "build_bazel_rules_nodejs", # Replace with a real SHA256 checksum sha256 = "006c1b5427f4450efd2f2496341f724b242179352ccd9b6a4451e55012b2bef8", # Replace with a real commit SHA strip_prefix = "rules_nodejs-469f9975bd8259ce130fadbbda3bec0ed5febe2b", urls = ["https://github.com/bazelbuild/rules_nodejs/archive/469f9975bd8259ce130fadbbda3bec0ed5febe2b.tar.gz"], )

http_archive( name="bazel_skylib", sha256="2b9af2de004d67725c9985540811835389b229c27874f2e15f5e319622a53a3b", strip_prefix="bazel-skylib-e9fc4750d427196754bebb0e2e1e38d68893490a", urls=["https://github.com/bazelbuild/bazel-skylib/archive/e9fc4750d427196754bebb0e2e1e38d68893490a.tar.gz"] )

http_archive( name = "io_bazel_rules_docker", sha256 = "29d109605e0d6f9c892584f07275b8c9260803bf0c6fcb7de2623b2bedc910bd", strip_prefix = "rules_docker-0.5.1", urls = ["https://github.com/bazelbuild/rules_docker/archive/v0.5.1.tar.gz"], )

elrapha avatar Sep 10 '18 13:09 elrapha

Marking as P1 because error messages

dslomov avatar Dec 07 '18 13:12 dslomov