Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

name 'json' is not defined #2938

Closed
JRodDynamite opened this issue Sep 12, 2021 · 4 comments
Closed

name 'json' is not defined #2938

JRodDynamite opened this issue Sep 12, 2021 · 4 comments

Comments

@JRodDynamite
Copy link

JRodDynamite commented Sep 12, 2021

🐞 bug report

Affected Rule

The issue is caused by the rule: `npm_install`

Is this a regression?

Yes, the previous version in which this bug was not present was: 3.0.0

Description

On updating rules_nodejs to version 4.1.0, I'm unable to build anything.

I even tried clearing the bazel clean --expunge and also rm -rf ~/.cache/bazel but still faced this issue.

🔬 Minimal Reproduction

Simply setting up the following code in the WORKSPACE and running bazel sync I was able to reproduce the issue

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

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

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

🔥 Exception or Error

> bazel sync
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: /home/jason/.cache/bazel/_bazel_jason/3e1bb1e4a7ba7cce5fa93aa0d10779e8/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:442:28: name 'json' is not defined
ERROR: /home/jason/.cache/bazel/_bazel_jason/3e1bb1e4a7ba7cce5fa93aa0d10779e8/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:554:20: name 'json' is not defined
ERROR: /home/jason/.cache/bazel/_bazel_jason/3e1bb1e4a7ba7cce5fa93aa0d10779e8/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:585:19: name 'json' is not defined
ERROR: error loading package '': in /home/jason/.cache/bazel/_bazel_jason/3e1bb1e4a7ba7cce5fa93aa0d10779e8/external/build_bazel_rules_nodejs/index.bzl: Extension 'internal/npm_install/npm_install.bzl' has errors
Loading: loading...

🌍 Your Environment

Operating System:

  CentOS Linux release 8.3.2011

Output of bazel version:

  bazel3-3.7.1-0.el7.x86_64

Rules_nodejs version:

  4.1.0
@thesayyn
Copy link
Collaborator

Hey there.

Problem is that you are running an old version of bazel which we don’t test against. json was introduced in bazel version 4.0.0 and we test against 4.1.0

Could you upgrade your bazel installation and try again?

@JRodDynamite
Copy link
Author

Could you upgrade your bazel installation and try again?

@thesayyn - Let me give that a try.

@alexeagle
Copy link
Collaborator

note that we do have some error checking for this case
https://github.com/bazelbuild/rules_nodejs/blob/stable/internal/node/node_repositories.bzl#L37-L43
but it seems that you didn't call node_repositories? or maybe bazel sync somehow doesn't run that check

@JRodDynamite
Copy link
Author

@alexeagle @thesayyn - Thanks a lot! Updating bazel to 4.2.1 resolved this issue for me. Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants