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

dev-infra: can't build project or run dev-app on MacBooks with m1 CPUs #23983

Closed
Splaktar opened this issue Nov 18, 2021 · 19 comments
Closed

dev-infra: can't build project or run dev-app on MacBooks with m1 CPUs #23983

Splaktar opened this issue Nov 18, 2021 · 19 comments
Assignees
Labels
area: dev-infra Issue related to internal project infrastructure P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent troubleshooting This issue is not reporting an issue, but just asking for help

Comments

@Splaktar
Copy link
Member

Splaktar commented Nov 18, 2021

What are you trying to do?

I've switched to an m1Max MacBook Pro as my main device now.

I've got Bazel 4.2.1 installed locally, but the build seems to be trying to install Bazel 4.0.0 and failing.

Screen Shot 2021-11-18 at 13 57 43

  1. Build the project
  2. Run the dev-app

What troubleshooting steps have you tried?

Setting my BAZEL environment variable as discussed in angular/angular#40498 (comment). This fixed Bazel builds for Framework, but not Components.

Reproduction

Steps to reproduce:

  1. yarn
  2. yarn build
splaktar-m1max:components splaktar$ yarn build
yarn run v1.22.17
$ ts-node --project scripts/tsconfig.json ./scripts/build-packages-dist.ts
######################################
  Building release packages...
######################################
2021/11/18 13:54:15 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64...
2021/11/18 13:54:15 could not download Bazel: HTTP GET https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64 failed with error 404
Error: Command failed: bazel query --output=label "attr('tags', '\[.*release-package.*\]', //src/...) intersect kind('.*_package', //src/...)"
    at checkExecSyncError (node:child_process:826:11)
    at execSync (node:child_process:900:15)
    at exec (/Users/splaktar/Git/angular/components/scripts/build-packages-dist.ts:137:26)
    at buildReleasePackages (/Users/splaktar/Git/angular/components/scripts/build-packages-dist.ts:69:19)
    at performDefaultSnapshotBuild (/Users/splaktar/Git/angular/components/scripts/build-packages-dist.ts:56:10)
    at Object.<anonymous> (/Users/splaktar/Git/angular/components/scripts/build-packages-dist.ts:43:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Module.m._compile (/Users/splaktar/Git/angular/components/node_modules/ts-node/src/index.ts:1310:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/splaktar/Git/angular/components/node_modules/ts-node/src/index.ts:1313:12) {
  status: 1,
  signal: null,
  output: [ null, Buffer(0) [Uint8Array] [], null ],
  pid: 63907,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: null
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  1. yarn dev-app
splaktar-m1max:components splaktar$ yarn dev-app
yarn run v1.22.17
$ ibazel run //src/dev-app:devserver
FATAL: Your platform/architecture combination darwin - arm64 is not yet supported.
    Follow install instructions at https://github.com/bazelbuild/bazel-watcher/blob/master/README.md to compile for your system.
node:internal/validators:119
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received an instance of Promise
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at normalizeSpawnArguments (node:child_process:503:3)
    at spawn (node:child_process:691:13)
    at main (/Users/splaktar/Git/angular/components/node_modules/@bazel/ibazel/index.js:82:18)
    at Object.<anonymous> (/Users/splaktar/Git/angular/components/node_modules/@bazel/ibazel/index.js:96:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  1. yarn test material/button
splaktar-m1max:components splaktar$ yarn test material/button
yarn run v1.22.17
$ node ./scripts/run-component-tests.js material/button
FATAL: Your platform/architecture combination darwin - arm64 is not yet supported.
    Follow install instructions at https://github.com/bazelbuild/bazel-watcher/blob/master/README.md to compile for your system.
node:internal/validators:119
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received an instance of Promise
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at normalizeSpawnArguments (node:child_process:503:3)
    at spawn (node:child_process:691:13)
    at main (/Users/splaktar/Git/angular/components/node_modules/@bazel/ibazel/index.js:82:18)
    at Object.<anonymous> (/Users/splaktar/Git/angular/components/node_modules/@bazel/ibazel/index.js:96:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}
/Users/splaktar/Git/angular/components/node_modules/shelljs/src/common.js:401
      if (config.fatal) throw e;
                        ^

Error: exec: FATAL: Your platform/architecture combination darwin - arm64 is not yet supported.
    Follow install instructions at https://github.com/bazelbuild/bazel-watcher/blob/master/README.md to compile for your system.
node:internal/validators:119
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received an instance of Promise
    at new NodeError (node:internal/errors:371:5)
    at validateString (node:internal/validators:119:11)
    at normalizeSpawnArguments (node:child_process:503:3)
    at spawn (node:child_process:691:13)
    at main (/Users/splaktar/Git/angular/components/node_modules/@bazel/ibazel/index.js:82:18)
    at Object.<anonymous> (/Users/splaktar/Git/angular/components/node_modules/@bazel/ibazel/index.js:96:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}

    at Object.error (/Users/splaktar/Git/angular/components/node_modules/shelljs/src/common.js:110:27)
    at execSync (/Users/splaktar/Git/angular/components/node_modules/shelljs/src/exec.js:102:12)
    at Object._exec (/Users/splaktar/Git/angular/components/node_modules/shelljs/src/exec.js:205:12)
    at Object.exec (/Users/splaktar/Git/angular/components/node_modules/shelljs/src/common.js:335:23)
    at Object.<anonymous> (/Users/splaktar/Git/angular/components/scripts/run-component-tests.js:102:9)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Environment

  • Angular: 13.0.1
  • CDK/Material: master
  • Browser(s): Chrome 95.0.4638.69 (Official Build) (arm64)
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS Monterey 12.0.1 (21A559)
  • Bazel: 4.2.1- (@non-git) /opt/local/bin/bazel
@Splaktar Splaktar added troubleshooting This issue is not reporting an issue, but just asking for help needs triage This issue needs to be triaged by the team labels Nov 18, 2021
@jelbourn jelbourn added area: dev-infra Issue related to internal project infrastructure P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Nov 18, 2021
@jelbourn jelbourn changed the title help(DEVELOPMENT): can't build project or run dev-app on MacBooks with m1 CPUs dev-infra: can't build project or run dev-app on MacBooks with m1 CPUs Nov 18, 2021
@devversion
Copy link
Member

As stated offline:

  • rules_webtesting has been made compatible with M1
  • The shared dev-infra package is also fully compatible

Though:

  • ibazel does not yet support Arm64. I got it working by locally building ibazel though. So it would be trivial landing this upstream.
  • The ConcatJS devserver (used in FW only), is not compatible as it is a native binary. rules_nodejs needs some help here.
  • Clang-format (used in FW only) seems to need an update. Looks like a new version is finally available (it was not before; and brew was needed)
  • Buildifier (for formatting) I think also needs an update to work with Arm64. Last time I checked it did not have a build available for arm64.
  • Webdriver Manager, used in FW and CLI (IIRC) does not work with arm64 either. Time to get off protractor?
  • Puppeteer does not pull native Arm64 m1 builds last time I checked. It used x86 and required Rosetta (please do not install! it's hard to get rid of it again)

just a summary of what I found already when I worked with M1

@pkirchniawy
Copy link

Any news on this issue?

@Splaktar
Copy link
Member Author

Splaktar commented Jan 6, 2022

@pkirchniawy nope, I still get the same errors as above when using the latest master. Since this is my primary machine, I consider this to be a P1 rather than a P3.

I went to the link in the error, but I'm not familiar enough with ibazel to build it locally like @devversion did. It would be helpful if we could have some specific steps for that in this issue or in our developer docs.

@Splaktar
Copy link
Member Author

Splaktar commented Jan 6, 2022

I guess that this might be the specific steps that need to be done to use your own locally built ibazel on an m1 mac:
https://github.com/bazelbuild/bazel-watcher/blob/master/README.md#compiling-yourself

@Splaktar
Copy link
Member Author

Splaktar commented Jan 6, 2022

Unfortunately, that didn't work for me as the local build failed since the rules_proto 404'd and it doesn't seem to like my bazel 4.2.1 installation:

Starting local Bazel server and connecting to it...
WARNING: Download from https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/9e4c622ba8c2178b71420ed3d14fb8874beee3a5.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
INFO: Analyzed target //ibazel:ibazel (65 packages loaded, 7364 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel_splaktar/8fee38e85ee44a13c2ac34d7c1f24c9d/external/com_github_fsnotify_fsevents/BUILD.bazel:3:11: GoCompilePkg external/com_github_fsnotify_fsevents/darwin_amd64_stripped/fsevents%/github.com/fsnotify/fsevents.a failed: (Exit 1): builder failed: error executing command bazel-out/host/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_amd64 -src external/com_github_fsnotify_fsevents/fsevents.go -src ... (remaining 31 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
xcrun: error: can't exec '/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_bazel/bazel/work/bazelwrap/cc' (errno=No such file or directory)
Error in child process '/usr/bin/xcrun'. 71
compilepkg: error running subcommand: exit status 2
Target //ibazel:ibazel failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 62.041s, Critical Path: 3.16s
INFO: 50 processes: 24 internal, 26 darwin-sandbox.
FAILED: Build did NOT complete successfully
$ bazel --version
bazel 4.2.1- (@non-git)

What version of bazel does this build expect? It seems like others are using 4.2.1 in other issues, so I think that this version might be okay?

It looks like this ibazel piece is blocked by

These issues (and an associated issue in a dependency) have been open since November 2021 and there doesn't appear to be anyone working on them.

@Splaktar
Copy link
Member Author

There is a PR open against bazel-watcher to add m1 mac support: bazelbuild/bazel-watcher#496. It could use some reviews.

@devversion
Copy link
Member

Also wanted to mention that I will be using M1 only for the next couple of weeks/and potentially months (as I had to move without my Windows machine). So I'm sure we'll be able to get to this very soon. Still want to mention though that I think the majority of workflows should work. The key really is currently using Bazel globally, and avoiding ibazel (or using a custom build)

@pkirchniawy
Copy link

pkirchniawy commented Jan 23, 2022

I was able to build ibazel locally based on the pr branch, but when running ´yarn dev-app´ it is still using ibazel from the npm package installed. Even after setting ibazel into the PATH and running the dev-app script directly in the terminal it shows me zsh: command not found: ibazel.

echo $PATH gives me this paths:
/Users/user/Code/m1-bazel-watcher/bazel-bin/ibazel/
/Users/user/Code/m1-bazel-watcher/bazel-bin/ibazel/darwin_arm64_pure_stripped

Any suggestions?

@devversion
Copy link
Member

@pkirchniawy you could run ibazel directly. e.g. ibazel run //src/dev-app:devserver

@pkirchniawy
Copy link

@pkirchniawy you could run ibazel directly. e.g. ibazel run //src/dev-app:devserver

Thanks! I've already tried that. But ibazel is not a valid command. After compiling it locally, I struggle with setting the PATH right. (https://github.com/bazelbuild/bazel-watcher#compiling-yourself). So when I type ibazel run, it tells me command not found: ibazel.

@devversion
Copy link
Member

interesting, that indicates that ibazel is not part of the PATH properly. I don't know to what you have set the PATH, but usually it should include a path pointing to the directory containing the ibazel executable binary.

@pkirchniawy
Copy link

echo $PATH gives me this paths:
/Users/user/Code/m1-bazel-watcher/bazel-bin/ibazel/
/Users/user/Code/m1-bazel-watcher/bazel-bin/ibazel/darwin_arm64_pure_stripped

@Splaktar
Copy link
Member Author

bazel-watcher has been updated in 0.16.2 to support m1 macs! 🚀

@Splaktar
Copy link
Member Author

If I bump

"@bazel/ibazel": "0.15.10",

to 0.16.2, I get farther but now I see this:

$ yarn dev-app
yarn run v1.22.17
$ ibazel run //src/dev-app:devserver
iBazel [1:57PM]: You are using an experimental filesystem watcher. If you would like to disable that, please set the environment variable
        IBAZEL_USE_LEGACY_WATCHER=1
iBazel [1:57PM]: Error getting Bazel info exit status 2
iBazel [1:57PM]: Querying for files to watch...
iBazel [1:57PM]: Error getting Bazel info exit status 2
Error finding remote repositories directory: exit status 2
iBazel [1:57PM]: Error getting Bazel info exit status 2
Error finding remote repositories directory: exit status 2
iBazel [1:57PM]: Running //src/dev-app:devserver
Loading: 
Loading: 0 packages loaded
ERROR: Failed to load Starlark extension '@npm//@bazel/protractor:package.bzl'.
Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @npm
 - @nodejs_darwin_arm64
This could either mean you have to add the '@nodejs_darwin_arm64' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.
ERROR: cycles detected during target parsing
INFO: Elapsed time: 0.120s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
iBazel [1:57PM]: Error running Bazel exit status 1
error Command failed with exit code 4.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@kevinpauer
Copy link

Had the same issue @Splaktar. Made it work for me following these steps.

  1. After forking the most recent angular/components release, I first had to downgrade me node version to 16.x.
  2. Followed this guide to compile ibazel on my device (honestly not sure if it did anything)
  3. Bumped up the ibazel version in my package.json from "@bazel/ibazel": "0.15.10" to "@bazel/ibazel": "0.16.2", this version seems to support the M1
  4. yarn then yarn dev-app first time did somehow fail, started again and it ran through

Hope this helps.

@RobertAKARobin
Copy link
Contributor

I'm trying to make a change to #24657. However, yarn test mdc-chips errors out:

$ yarn test mdc-chips
yarn run v1.22.17
$ node ./scripts/run-component-tests.js mdc-chips
FATAL: Your platform/architecture combination darwin - arm64 is not yet supported.
    Follow install instructions at https://github.com/bazelbuild/bazel-watcher/blob/master/README.md to compile for your system.

Based on @kevinpauer 's comment above I tried manually updating @bazel/ibazel to 0.16.2 in package.json, then ran yarn, then tried yarn test mdc-chips again, with a different error:

$ yarn test mdc-chips
yarn run v1.22.17
$ node ./scripts/run-component-tests.js mdc-chips
iBazel [5:08PM]: You are using an experimental filesystem watcher. If you would like to disable that, please set the environment variable
	IBAZEL_USE_LEGACY_WATCHER=1
iBazel [5:08PM]: Error getting Bazel info exit status 1
iBazel [5:08PM]: Querying for files to watch...
iBazel [5:08PM]: Error getting Bazel info exit status 1
Error finding remote repositories directory: exit status 1
iBazel [5:08PM]: Error getting Bazel info exit status 1
Error finding remote repositories directory: exit status 1
iBazel [5:08PM]: Testing //src/material-experimental/mdc-chips:unit_tests_chromium
2022/06/27 17:08:20 Downloading https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64...
2022/06/27 17:08:20 could not download Bazel: HTTP GET https://releases.bazel.build/4.0.0/release/bazel-4.0.0-darwin-arm64 failed with error 404
iBazel [5:08PM]: Build error: exit status 1

I'm unsure how to proceed from here.

@devversion
Copy link
Member

@RobertAKARobin thx for the details. I think your branch is outdated and would need a rebase. We updated both the bazel-watcher and Bazel already to an M1 compatible version.

@RobertAKARobin
Copy link
Contributor

That worked, thanks!

@devversion devversion self-assigned this Jul 1, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: dev-infra Issue related to internal project infrastructure P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent troubleshooting This issue is not reporting an issue, but just asking for help
Projects
None yet
Development

No branches or pull requests

7 participants