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

error node_toolchain on apple silicon #2779

Closed
janboeye opened this issue Jun 18, 2021 · 5 comments · Fixed by #2796
Closed

error node_toolchain on apple silicon #2779

janboeye opened this issue Jun 18, 2021 · 5 comments · Fixed by #2796
Assignees

Comments

@janboeye
Copy link

janboeye commented Jun 18, 2021

🐞 bug report

Affected Rule

node_repositories()

Is this a regression?

This works on a x86_64 mac, but not on an M1 mac.

Description

generating BUILD in nodejs_darwin_arm64_config is not correct, and it crash bazel

package(default_visibility = ["//visibility:public"])

load("@build_bazel_rules_nodejs//toolchains/node:node_toolchain.bzl", "node_toolchain")

node_toolchain(
    name = "toolchain",
    target_tool = "//external:node"

)

🔬 Minimal Reproduction

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

node_repositories(
    node_repositories = {
        "16.3.0-linux_arm64": ("node-v16.3.0-linux-arm64.tar.gz", "node-v16.3.0-linux-arm64", "7040a1f2a0a1aa9cf0f66ec46d0049c6638cb4c05490c13ca71d298fa94ed8ce"),
        "16.3.0-linux_amd64": ("node-v16.3.0-linux-x64.tar.gz", "node-v16.3.0-linux-x64", "86f6d06c05021ae73b51f57bb56569a2eebd4a2ecc0b881972a0572e465b5d27"),
        "16.3.0-darwin_amd64": ("node-v16.3.0-darwin-x64.tar.gz", "node-v16.3.0-darwin-x64", "3e075bcfb6130dda84bfd04633cb228ec71e72d9a844c57efb7cfff130b4be89"),
        "16.3.0-darwin_arm64": ("node-v16.3.0-darwin-arm64.tar.gz", "node-v16.3.0-darwin-arm64", "aeac294dbe54a4dfd222eedfbae704b185c40702254810e2c5917f6dbc80e017"),
        "16.3.0-windows_amd64": ("node-v16.3.0-win-x64.zip", "node-v16.3.0-win-x64", "3352e58d3603cf58964409d07f39f3816285317d638ddb0a0bf3af5deb2ff364"),
    },
    node_version = "16.3.0",
)

# TODO give this a name like `gui2_npm` once the @bazel/karma tools can tolerate a name other than `npm`
yarn_install(
    name = "npm",
    package_json = "//web/gui2:package.json",
    use_global_yarn_cache = True,
    yarn_lock = "//web/gui2:yarn.lock",
)

npm_install(
    # Name this npm so that Bazel Label references look like @npm//package
    name = "gui1_npm",
    package_json = "//tools/gui:package.json",
    package_lock_json = "//tools/gui:package-lock.json",
)

🔥 Exception or Error

Starting local Bazel server and connecting to it...
Analyzing: target //:onos (895 packages loaded, 13272 targets configured)
    Fetching @gui1_npm; Running npm install on //tools/gui:package.json
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ConfiguredTargetKey{label=//external:node, config=null}' (requested by nodes 'ConfiguredTargetKey{label=@nodejs_darwin_arm64_config//:toolchain, config=BuildConfigurationValue.Key[043853d3a556f41602438337957ff3cfb2c69109ef71ff409c774bcf37b8bfec]}')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:563)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.util.NoSuchElementException: No value present
        at java.base/java.util.Optional.get(Unknown Source)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:257)
        at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:938)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1018)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:371)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:477)
        ... 7 more

🌍 Your Environment

Operating System:

  
macos BIG SUR 11.4
  

Output of bazel version:

  
Build label: 4.1.0-homebrew
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jan 1 00:00:00 1980 (315532800)
Build timestamp: 315532800
Build timestamp as int: 315532800
  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  
RULES_NODEJS_VERSION = "3.6.0"

RULES_NODEJS_SHA256 = "0fa2d443571c9e02fcb7363a74ae591bdcce2dd76af8677a95965edf329d778a"

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

It is strange why toolchain is set to external:node.

@janboeye janboeye reopened this Jun 18, 2021
@janboeye
Copy link
Author

yarn_install will call _node_repositories(), this will make nodejs_darwin_arm64_config/BUILD.bzl wrong toolchain config on M1 mac.

it is caused by commit 2ad950f.

@alexeagle
Copy link
Collaborator

I got an M1 mac now, so I can reproduce and fix :)

@alexeagle alexeagle self-assigned this Jun 27, 2021
alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jun 28, 2021
alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jun 28, 2021
@alexeagle
Copy link
Collaborator

@janboeye this error is actually caused by having a node version before 16. The error handling is bad, which I just put up a PR for it. But something is running node_repositories before you did in the WORKSPACE file and therefore picking up a default version instead. You'll have to poke around to see what could be doing it (try just moving your node_repositories call earlier until you see the behavior change, then you'll know which other statement was causing it)

janboeye pushed a commit to janboeye/rules_nodejs that referenced this issue Jun 28, 2021
@janboeye
Copy link
Author

@alexeagle Thanks for the patch and suggestion, this patch is great.

alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jul 1, 2021
alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jul 2, 2021
alexeagle added a commit that referenced this issue Jul 2, 2021
alexeagle added a commit that referenced this issue Jul 2, 2021
twheys pushed a commit to twheys/rules_nodejs that referenced this issue Jan 13, 2022
@EdSchouten
Copy link

Did we ever file an issue against bazelbuild/bazel regarding the crash of Bazel itself?

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

Successfully merging a pull request may close this issue.

3 participants