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

examples/create-react-app is broken on Apple M1 #3101

Closed
z-k-r opened this issue Nov 27, 2021 · 2 comments
Closed

examples/create-react-app is broken on Apple M1 #3101

z-k-r opened this issue Nov 27, 2021 · 2 comments

Comments

@z-k-r
Copy link

z-k-r commented Nov 27, 2021

🐞 bug report

Affected Rule

create-react-app example

Is this a regression?

No

Description

Example for create-react-app does not built on Apple M1 because NodeJS versions below 16 are not supported (relevant)

🔬 Minimal Reproduction

On an Apple M1 machine, run:

git clone https://github.com/bazelbuild/rules_nodejs.git
cd rules_nodejs/examples/create-react-app
bazel run //:start

It results in the error seen below. Same command succeeds when run on Ubuntu (I don't have an Intel Mac ready to test)

🔥 Exception or Error


INFO: Repository npm instantiated at:
  /Users/zak/src/external/rules_nodejs/examples/create-react-app/WORKSPACE:25:13: in 
  /private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/index.bzl:83:18: in yarn_install
Repository rule yarn_install defined at:
  /private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl:917:31: in 
ERROR: An error occurred during the fetch of repository 'npm':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 814, column 31, in _yarn_install_impl
		node = repository_ctx.path(get_node_label(repository_ctx))
Error in path: Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
ERROR: Error fetching repository: Traceback (most recent call last):
	File "/private/var/tmp/_bazel_zak/cb27351f3f761fcb61f542608d914ae9/external/build_bazel_rules_nodejs/internal/npm_install/npm_install.bzl", line 814, column 31, in _yarn_install_impl
		node = repository_ctx.path(get_node_label(repository_ctx))
Error in path: Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
ERROR: Skipping '//:start': no such package '@npm//react-scripts': Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
WARNING: Target pattern parsing failed.
ERROR: no such package '@npm//react-scripts': Unable to load package for @nodejs_darwin_arm64//:bin/node: The repository '@nodejs_darwin_arm64' could not be resolved
INFO: Elapsed time: 0.163s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading:

🌍 Your Environment

Operating System:

  
MacOS 11.6 Big Sur
  

Output of bazel version:

  
Build label: 4.2.1
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Aug 30 15:23:11 2021 (1630336991)
Build timestamp: 1630336991
Build timestamp as int: 1630336991
  

Rules_nodejs version:

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

  
latest stable (653600d99cd8be75ba1f149a1a5d95a67354ea2d)
  

Anything else relevant?
Proposed fix inspired by @PengKuang in discussion for #2733

@thesayyn
Copy link
Collaborator

thesayyn commented Dec 2, 2021

this is mainly caused by the missing arm version of nodejs distributions. what we could do is improve the error message so that users know what to do when get encounter this.

@alexeagle
Copy link
Collaborator

Yup what @thesayyn said. To be precise, the default node is 14.17.5 https://docs.aspect.dev/bazelbuild/rules_nodejs/4.4.2/docs/builtins.html#node_repositories-node_version
and NodeJS doesn't ship a darwin-arm release for that version.

adding

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

node_repositories(
    node_version = "16.1.0",
)

to the example fixes it.

I suspect the right answer for this issue is that we should update the default node version in our 5.0 release (it's a breaking change)

https://github.com/bazelbuild/rules_nodejs/blob/5.x/nodejs/repositories.bzl#L11
since node 16 entered LTS on 2021-10-26 https://nodejs.org/en/about/releases/

alexeagle added a commit that referenced this issue Dec 2, 2021
As of 2021-10-26, v16 has entered LTS, so it's the most appropriate default.
Also, it provides darwin_arm releases (apple silicon) which many developers now expect.

BREAKING CHANGE:
The default nodejs version is now 16.12.0. To go back to the previous default, put this in your WORKSPACE:

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

node_repositories(
    node_version = "14.17.5",
)
```

Fixes #3101
alexeagle added a commit that referenced this issue Dec 2, 2021
As of 2021-10-26, v16 has entered LTS, so it's the most appropriate default.
Also, it provides darwin_arm releases (apple silicon) which many developers now expect.

BREAKING CHANGE:
The default nodejs version is now 16.12.0.
To go back to the previous default, put this in your WORKSPACE:

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

node_repositories(
    node_version = "14.17.5",
)
```

Fixes #3101
alexeagle added a commit that referenced this issue Dec 2, 2021
As of 2021-10-26, v16 has entered LTS, so it's the most appropriate default.
Also, it provides darwin_arm releases (apple silicon) which many developers now expect.

BREAKING CHANGE:
The default nodejs version is now 16.12.0.
To go back to the previous default, put this in your WORKSPACE:

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

node_repositories(
    node_version = "14.17.5",
)
```

Fixes #3101
alexeagle added a commit that referenced this issue Dec 2, 2021
As of 2021-10-26, v16 has entered LTS, so it's the most appropriate default.
Also, it provides darwin_arm releases (apple silicon) which many developers now expect.

BREAKING CHANGE:
The default nodejs version is now 16.12.0.
To go back to the previous default, put this in your WORKSPACE:

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

node_repositories(
    node_version = "14.17.5",
)
```

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

Successfully merging a pull request may close this issue.

3 participants