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

Yarn install runs on every build #3515

Closed
yohcop opened this issue Jul 31, 2022 · 3 comments
Closed

Yarn install runs on every build #3515

yohcop opened this issue Jul 31, 2022 · 3 comments

Comments

@yohcop
Copy link

yohcop commented Jul 31, 2022

🐞 bug report

Affected Rule

The issue is caused by the rule: rules_nodejs

Is this a regression?

I don't think so, but I'm not sure.

Description

On every build, even a "repeat build" immediately after a successful build, yarn install is re-ran, even if package.json, or yarn.lock are unchanged.

🔬 Minimal Reproduction

bazel build //some:target # -> success
bazel build //some:target # -> reruns yarn install

🌍 Your Environment

Operating System:

  
$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
  

Output of bazel version:

  
$ bazel version
Build label: 5.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed Jan 19 14:08:54 2022 (1642601334)
Build timestamp: 1642601334
Build timestamp as int: 1642601334
  

Rules_nodejs version:

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

  
$ cat WORKSPACE | grep -B1 -A3 build_bazel_rules_nodejs
http_archive(
    name = "build_bazel_rules_nodejs",
    sha256 = "e328cb2c9401be495fa7d79c306f5ee3040e8a03b2ebb79b022e15ca03770096",
    urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.2/rules_nodejs-5.4.2.tar.gz"],
)
$ cat package.json | grep bazel
    "@bazel/esbuild": "5.4.2",
    "@bazel/jasmine": "5.4.2",
    "@bazel/typescript": "5.4.2",
  

Anything else relevant?

See this trace from the second build which should be near instant.
Screenshot 2022-07-31 11 12 11

You can see the //external:npm running for nearly 17s in my project, out of the 25 total for that build.

This is especially visible and costly with ibazel when the incremental rebuilds should be very small.

@alexeagle
Copy link
Collaborator

See #1627 - are you really running just bazel build twice in a row and see a re-install? Bazel would only do that if something has changed.

@yohcop
Copy link
Author

yohcop commented Jul 31, 2022

Yes, I'm running just 2 bazel builds in a row.
I've checked the linked bug, and added --incompatible_strict_action_env as well as the debug options you suggested on that bug.

All I see in the rebuild explain file is this after the second rebuild:

Build options: --repository_cache='~/.cache/bazel/repository_cache' --incompatible_strict_action_env --strategy='TypeScriptCompile=worker' --define='context=local' --explain=/tmp/rebuild --verbose_explanations --announce_rc
Executing action 'BazelWorkspaceStatusAction stable-status.txt': unconditional execution is requested.

Nothing about nodejs / yarn / npm...

I couldn't find a way to have the line "running yarn install" in some text log (even with --curses=no...), so I recorded a video:

Screen.recording.2022-08-01.00.56.49.webm

Thanks,

@yohcop
Copy link
Author

yohcop commented Sep 12, 2022

I did more digging on this. I couldn't find the real reason I suppose, but adding symlink_node_modules = True to the WORKSPACE file in yarn_install() more or less solved it: it's either still running but is blazing fast, or it's no longer running that yarn install step (I think it's the later, as I can't seem to find the same step in the profile file.) 😀 .

I'll close for now.

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

2 participants