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

install_bazel_dependencies doesn't always update correctly #1200

Closed
JaredNeil opened this issue Sep 26, 2019 · 2 comments
Closed

install_bazel_dependencies doesn't always update correctly #1200

JaredNeil opened this issue Sep 26, 2019 · 2 comments

Comments

@JaredNeil
Copy link
Contributor

JaredNeil commented Sep 26, 2019

🐞 bug report

Affected Rule

The issue is caused by the rule: yarn_install / install_bazel_dependencies

Is this a regression?

Unsure.

Description

When updating the version of an NPM dependency that declares "bazelWorkspaces", the new version will not be installed into the workspace when install_bazel_dependencies() is called. After a bazel clean --expunge the correct version is installed. Alternatively, modifying the contents of the _bazel_workspace_marker file also causes it to install correctly.

The copy in external/npm/_workspaces/ is updated correctly, but it doesn't get copied to external/ unless I change the _bazel_workspace_marker file.

🔬 Minimal Reproduction

I was able to consistently reproduce it in examples/angular by building a custom version of @bazel/typescript, but it was pretty convoluted. I'll work on a simpler case if needed.

Edit: Repro steps (commits from master...lucidsoftware:jaredneil-install-repro)

bazelisk clean --expunge
git checkout 29b82f088c37785804096ef1e56e0f10449ad64b
bazelisk query //:tsconfig.json
grep "version" $(bazelisk info output_base)/external/npm/_workspaces/npm_bazel_typescript/package.json
grep "version" $(bazelisk info output_base)/external/npm_bazel_typescript/package.json
git checkout c0b6e4be12ba925560b8b16560dfb7f65b19f73b
bazelisk query //:tsconfig.json
grep "version" $(bazelisk info output_base)/external/npm/_workspaces/npm_bazel_typescript/package.json
grep "version" $(bazelisk info output_base)/external/npm_bazel_typescript/package.json

Output from running:

~/code/rules_nodejs/examples/angular$ bazelisk clean --expunge
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
WARNING: Waiting for server process to terminate (waited 5 seconds, waiting at most 60)
~/code/rules_nodejs/examples/angular$ git checkout 29b82f088c37785804096ef1e56e0f10449ad64b
Note: switching to '29b82f088c37785804096ef1e56e0f10449ad64b'.
HEAD is now at 29b82f0 Base commit for repro case
~/code/rules_nodejs/examples/angular$ bazelisk query //:tsconfig.json
Starting local Bazel server and connecting to it...

< ... >
    
//:tsconfig.json
Loading: 1 packages loaded
~/code/rules_nodejs/examples/angular$ grep "version" $(bazelisk info output_base)/external/npm/_workspaces/npm_bazel_typescript/package.json
    "version": "0.37.0",
~/code/rules_nodejs/examples/angular$ grep "version" $(bazelisk info output_base)/external/npm_bazel_typescript/package.json
    "version": "0.37.0",
~/code/rules_nodejs/examples/angular$ git checkout c0b6e4be12ba925560b8b16560dfb7f65b19f73b
Previous HEAD position was 29b82f0 Base commit for repro case
HEAD is now at c0b6e4b Show update failed
~/code/rules_nodejs/examples/angular$ bazelisk query //:tsconfig.json

< ... >
    
//:tsconfig.json
Loading: 1 packages loaded
~/code/rules_nodejs/examples/angular$ grep "version" $(bazelisk info output_base)/external/npm/_workspaces/npm_bazel_typescript/package.json
    "version": "0.37.1",
~/code/rules_nodejs/examples/angular$ grep "version" $(bazelisk info output_base)/external/npm_bazel_typescript/package.json
    "version": "0.37.0",

🌍 Your Environment

Operating System:

  
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:        18.04
Codename:       bionic
  

Output of bazel version:

  
Bazelisk version: v1.0
Build label: 0.29.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Sep 10 13:44:39 2019 (1568123079)
Build timestamp: 1568123079
Build timestamp as int: 1568123079
  

Rules version (SHA):

  
051b59217d1dba945f77c7f4d40638a6eb2b830e
  
@JaredNeil
Copy link
Contributor Author

Including a hash of the lock file in the marker file instead of adding the lock file as an additional input to the generated _maybe(copy_repository, ...) rule seems to fix it.

@alexeagle
Copy link
Collaborator

Thanks for the fix!

JaredNeil added a commit to lucidsoftware/rules_nodejs that referenced this issue Oct 3, 2019
JaredNeil added a commit to lucidsoftware/rules_nodejs that referenced this issue Oct 3, 2019
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