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 while resolving toolchains for target in @npm//@bazel/labs/grpc_web on M1 Mac (arm64) #2733

Closed
vinayreddy opened this issue Jun 2, 2021 · 11 comments
Labels
Can Close? We will close this in 30 days if there is no further activity

Comments

@vinayreddy
Copy link

Affected Rule

ts_proto_library()

Is this a regression?

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

Description

Generating typescript/javascript files for protobufs on an arm64 M1 mac fails.

🔬 Minimal Reproduction

Single proto file that used to work on an intel mac but doesn't work on an M1 mac: https://github.com/vinayreddy/experimental/tree/master/proto

🔥 Exception or Error


$ bazel build --define=VERBOSE_LOGS=1 proto/...
INFO: SHA256 (https://golang.org/dl/?mode=json&include=all) = c71d9d3a5e2d4baaa5ae93319092dde1d43670c2ddf0ee38507695792febe51d
ERROR: While resolving toolchains for target @npm//@bazel/labs/grpc_web:change_import_style: no matching toolchains found for types @build_bazel_rules_nodejs//toolchains/node:toolchain_type
ERROR: Analysis of target '//proto:calculator_ts_proto' failed; build aborted: no matching toolchains found for types @build_bazel_rules_nodejs//toolchains/node:toolchain_type
INFO: Elapsed time: 13.075s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (105 packages loaded, 8374 targets configured)

🌍 Your Environment

Operating System:

  
macOS Big Sur (11.2.3) M1, macbook air.
  

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:

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

My package.json is as follows:

  
{
 "name": "grpc-calculator",
 "version": "0.1.0",
 "description": "gRPC-Web Calculator",
 "dependencies": {
   "@bazel/labs": "^3.5.1",
   "@bazel/typescript": "^3.5.1",
   "@grpc/grpc-js": "^1.3.2",
   "@grpc/proto-loader": "^0.3.0",
   "google-protobuf": "^3.17.1",
   "grpc-web": "^1.2.1",
   "protoc-gen-ts": "^0.3.6-rc4",
   "ts-protoc-gen": "^0.15.0",
   "typescript": "^4.3.2",
   "webpack": "^5.38.1"
 }
}
 

When I build I see references to amd64 on the command-line from npm, and I suspect this is what is causing the problem. I'm unsure how to make npm use an arm64 version instead.

@alexeagle
Copy link
Collaborator

Hmm, I don't have a way to test this (can't Apple ship one of these things to all OSS maintainers when they make such a big change?)

Can you tell if this is specific to the labs package, or affects everything in rules_nodejs? Are you able to build anything that depends on a nodejs tool (say a ts_project?)
That would help me isolate the problem.

@vinayreddy
Copy link
Author

I wrote a basic hello world typescript program and tried building it with ts_project and get the same error

$ bazel build ts/...
Starting local Bazel server and connecting to it...
INFO: SHA256 (https://golang.org/dl/?mode=json&include=all) = 5ed3122b5b077c73e0df19e1782333da61619cb04525eed23d9da7de0f904183
ERROR: While resolving toolchains for target @npm//typescript/bin:tsc: no matching toolchains found for types @build_bazel_rules_nodejs//toolchains/node:toolchain_type
ERROR: Analysis of target '//ts:hello_ts' failed; build aborted: no matching toolchains found for types @build_bazel_rules_nodejs//toolchains/node:toolchain_type
INFO: Elapsed time: 8.124s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (16 packages loaded, 139 targets configured)

@vinayreddy
Copy link
Author

Happy to try any patches (that add more diagnostic info) to help speed up debugging.

@alexeagle
Copy link
Collaborator

Seems like the mistake would have to be around here
730e8a5#diff-fa187ecdfe9af82b6b99314cff28a3ab78b4d9cf3d74e7e2b48d51ce1b4b0a21

What's the output from running uname -m ?

@vinayreddy
Copy link
Author

$ uname -m
arm64

alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jun 8, 2021
alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jun 8, 2021
alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jun 8, 2021
alexeagle added a commit to alexeagle/rules_nodejs that referenced this issue Jun 8, 2021
@khanhtc1202
Copy link

khanhtc1202 commented Jun 17, 2021

Hi @alexeagle, since this #2754 PR was merged, suppose it should be fine, but another error appeared on rules_nodejs v3.6.0 😓

Affected Rule: yarn_install

(16:07:44) ERROR: An error occurred during the fetch of repository 'npm':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 684, column 37, in _yarn_install_impl
		_add_node_repositories_info_deps(repository_ctx)
	File "/private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 433, column 27, in _add_node_repositories_info_deps
		repository_ctx.symlink(
Error in symlink: Not a regular file: /private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/nodejs_darwin_arm64/node_info
(16:07:44) ERROR: Error fetching repository: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 684, column 37, in _yarn_install_impl
		_add_node_repositories_info_deps(repository_ctx)
	File "/private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 433, column 27, in _add_node_repositories_info_deps
		repository_ctx.symlink(
Error in symlink: Not a regular file: /private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/nodejs_darwin_arm64/node_info
(16:07:44) ERROR: no such package '@npm//@bazel/labs': Not a regular file: /private/var/tmp/_bazel_s12228/8853970899baaeb63ca98792c8fae39a/external/nodejs_darwin_arm64/node_info

Do we have any plan to support M1 Mac in the near future? 👀

@alexeagle alexeagle reopened this Jun 21, 2021
ramuuns pushed a commit to ramuuns/rules_nodejs that referenced this issue Jun 29, 2021
@sayrer
Copy link

sayrer commented Aug 21, 2021

So, this does work now, if you specify a new enough Node version.

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

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

# M1 Macs require Node 16+
node_repositories(
    package_json = ["//:package.json"],
    node_version = "16.6.2",
)

I managed to get this error to print once, which is how I figured this issue out. But that error doesn't print in most cases, causing much confusion.

@PengKuang
Copy link

PengKuang commented Nov 4, 2021

So, this does work now, if you specify a new enough Node version.

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

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

# M1 Macs require Node 16+
node_repositories(
    package_json = ["//:package.json"],
    node_version = "16.6.2",
)

I managed to get this error to print once, which is how I figured this issue out. But that error doesn't print in most cases, causing much confusion.

I still see errors after adopting this solution for my mac with m1:

ERROR: An error occurred during the fetch of repository 'nodejs_darwin_amd64': Traceback (most recent call last): File "/private/var/tmp/_bazel_pengkuang/42c7e433c8424387404b45dd43df7500/external/build_bazel_rules_nodejs/internal/node/node_repositories.bzl", line 709, column 19, in _nodejs_repo_impl _download_node(repository_ctx) File "/private/var/tmp/_bazel_pengkuang/42c7e433c8424387404b45dd43df7500/external/build_bazel_rules_nodejs/internal/node/node_repositories.bzl", line 290, column 13, in _download_node fail("Unknown NodeJS version-host %s" % version_host_os) Error in fail: Unknown NodeJS version-host 17.0.1-darwin_amd64 ERROR: Error fetching repository: Traceback (most recent call last): File "/private/var/tmp/_bazel_pengkuang/42c7e433c8424387404b45dd43df7500/external/build_bazel_rules_nodejs/internal/node/node_repositories.bzl", line 709, column 19, in _nodejs_repo_impl _download_node(repository_ctx) File "/private/var/tmp/_bazel_pengkuang/42c7e433c8424387404b45dd43df7500/external/build_bazel_rules_nodejs/internal/node/node_repositories.bzl", line 290, column 13, in _download_node fail("Unknown NodeJS version-host %s" % version_host_os) Error in fail: Unknown NodeJS version-host 17.0.1-darwin_amd64 ERROR: /Users/pengkuang/gerrit/BUILD:35:8: error loading package 'polygerrit-ui/app': Encountered error while reading extension file '@bazel/typescript/index.bzl': no such package '@npm//@bazel/typescript': no such package '@nodejs_darwin_amd64//': Unknown NodeJS version-host 17.0.1-darwin_amd64 and referenced by '//:gerrit' ERROR: Analysis of target '//:gerrit' failed; build aborted: Analysis failed INFO: Elapsed time: 0,272s INFO: 0 processes. FAILED: Build did NOT complete successfully (2 packages loaded, 1 targ\ et configured)

@vpanta
Copy link
Contributor

vpanta commented Nov 15, 2021

@PengKuang

ERROR: An error occurred during the fetch of repository 'nodejs_darwin_amd64': ...

amd64 isn't an arch for node. Did you mean x64 or arm64? Maybe a typo in your configuration?

twheys pushed a commit to twheys/rules_nodejs that referenced this issue Jan 13, 2022
@mattem mattem added Can Close? We will close this in 30 days if there is no further activity and removed need: more info labels Feb 26, 2022
@mattem
Copy link
Collaborator

mattem commented Feb 26, 2022

Given the labs package no longer exists, and the linked fix in #3339 is merged, I think this can be closed.

@mattem mattem closed this as completed Feb 26, 2022
@ng-druid
Copy link

ng-druid commented Apr 2, 2022

So, this does work now, if you specify a new enough Node version.

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

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

# M1 Macs require Node 16+
node_repositories(
    package_json = ["//:package.json"],
    node_version = "16.6.2",
)

I managed to get this error to print once, which is how I figured this issue out. But that error doesn't print in most cases, causing much confusion.

Life saver.

I have been trying to migrate a node lambda that was originally created on an intel mac. Have run into several problems including this one. Your comment solved my issue. thanks

amuramoto added a commit to googlemaps/openapi-specification that referenced this issue Jan 11, 2023
- Removes deprecated managed_directories, see bazelbuild/bazel#15463
-  Fixes issue with @build_bazel_rules_nodejs, see bazel-contrib/rules_nodejs#2733 (comment)
- Sets test action to use Ubuntu-20.04 because it's needed for pkg_tar (bazelbuild/bazel#11554) since python2 was removed from Ubuntu after 20.04.
googlemaps-bot pushed a commit to googlemaps/openapi-specification that referenced this issue Jan 11, 2023
## [1.22.1](v1.22.0...v1.22.1) (2023-01-11)

### Bug Fixes

* Fixes various deprecations in test action ([#425](#425)) ([1efae2f](1efae2f)), closes [/github.com/bazel-contrib/rules_nodejs/issues/2733#issuecomment-903111659](https://github.com//github.com/bazelbuild/rules_nodejs/issues/2733/issues/issuecomment-903111659)
* sets release action to use ubuntu-20.04 ([4dc4034](4dc4034))
* sets semantic release version to 19 in release action ([f6ac071](f6ac071))
amuramoto added a commit to googlemaps/openapi-specification that referenced this issue Jan 12, 2023
- Removes deprecated managed_directories, see bazelbuild/bazel#15463
-  Fixes issue with @build_bazel_rules_nodejs, see bazel-contrib/rules_nodejs#2733 (comment)
- Sets test action to use Ubuntu-20.04 because it's needed for pkg_tar (bazelbuild/bazel#11554) since python2 was removed from Ubuntu after 20.04.
amuramoto pushed a commit to googlemaps/openapi-specification that referenced this issue Jan 12, 2023
## [1.22.1](v1.22.0...v1.22.1) (2023-01-11)

### Bug Fixes

* Fixes various deprecations in test action ([#425](#425)) ([1efae2f](1efae2f)), closes [/github.com/bazel-contrib/rules_nodejs/issues/2733#issuecomment-903111659](https://github.com//github.com/bazelbuild/rules_nodejs/issues/2733/issues/issuecomment-903111659)
* sets release action to use ubuntu-20.04 ([4dc4034](4dc4034))
* sets semantic release version to 19 in release action ([f6ac071](f6ac071))
amuramoto added a commit to googlemaps/openapi-specification that referenced this issue Jan 12, 2023
- Removes deprecated managed_directories, see bazelbuild/bazel#15463
-  Fixes issue with @build_bazel_rules_nodejs, see bazel-contrib/rules_nodejs#2733 (comment)
- Sets test action to use Ubuntu-20.04 because it's needed for pkg_tar (bazelbuild/bazel#11554) since python2 was removed from Ubuntu after 20.04.
amuramoto pushed a commit to googlemaps/openapi-specification that referenced this issue Jan 12, 2023
## [1.22.1](v1.22.0...v1.22.1) (2023-01-11)

### Bug Fixes

* Fixes various deprecations in test action ([#425](#425)) ([1efae2f](1efae2f)), closes [/github.com/bazel-contrib/rules_nodejs/issues/2733#issuecomment-903111659](https://github.com//github.com/bazelbuild/rules_nodejs/issues/2733/issues/issuecomment-903111659)
* sets release action to use ubuntu-20.04 ([4dc4034](4dc4034))
* sets semantic release version to 19 in release action ([f6ac071](f6ac071))
amuramoto added a commit to googlemaps/openapi-specification that referenced this issue Feb 2, 2023
- Removes deprecated managed_directories, see bazelbuild/bazel#15463
-  Fixes issue with @build_bazel_rules_nodejs, see bazel-contrib/rules_nodejs#2733 (comment)
- Sets test action to use Ubuntu-20.04 because it's needed for pkg_tar (bazelbuild/bazel#11554) since python2 was removed from Ubuntu after 20.04.
amuramoto pushed a commit to googlemaps/openapi-specification that referenced this issue Feb 2, 2023
## [1.22.1](v1.22.0...v1.22.1) (2023-01-11)

### Bug Fixes

* Fixes various deprecations in test action ([#425](#425)) ([1efae2f](1efae2f)), closes [/github.com/bazel-contrib/rules_nodejs/issues/2733#issuecomment-903111659](https://github.com//github.com/bazelbuild/rules_nodejs/issues/2733/issues/issuecomment-903111659)
* sets release action to use ubuntu-20.04 ([4dc4034](4dc4034))
* sets semantic release version to 19 in release action ([f6ac071](f6ac071))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? We will close this in 30 days if there is no further activity
Projects
None yet
Development

No branches or pull requests

8 participants