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

[Bug]: update_pnpm_lock fails under Bzlmod, retry fixes it #1445

Closed
alexeagle opened this issue Jan 16, 2024 · 3 comments
Closed

[Bug]: update_pnpm_lock fails under Bzlmod, retry fixes it #1445

alexeagle opened this issue Jan 16, 2024 · 3 comments
Assignees
Labels
bug Something isn't working funding needed Contribute to https://opencollective.com/aspect-build

Comments

@alexeagle
Copy link
Member

alexeagle commented Jan 16, 2024

What happened?

Under bzlmod, update_pnpm_lock fails on the first attempt.

Version

HEAD

How to reproduce

In rules_js,

  1. cd e2e/npm_translate_lock
  2. modify package.json, like "semver": "7.5.4"

then bazel build ... gives an error:

~/Projects/rules_js/e2e/npm_translate_lock$ bazel build --enable_bzlmod ...
Starting local Bazel server and connecting to it...
ERROR: Skipping '...': error loading package under directory '': error loading package '': at /shared/cache/bazel/user_base/3b36aba3ddc6cb653f7aaaed8bb07c4d/external/aspect_rules_js~override~npm~npm/defs.bzl:40:6: Unable to find package for @aspect_rules_js~override~npm~npm__semver__registry.npmjs.org_semver_7.5.4__links//:defs.bzl: The repository '@aspect_rules_js~override~npm~npm__semver__registry.npmjs.org_semver_7.5.4__links' could not be resolved: Repository '@aspect_rules_js~override~npm~npm__semver__registry.npmjs.org_semver_7.5.4__links' is not defined.

Simply running the same bazel build command again fixes it.

Any other information?

No response

@alexeagle alexeagle added the bug Something isn't working label Jan 16, 2024
@github-actions github-actions bot added the untriaged Requires traige label Jan 16, 2024
@alexeagle
Copy link
Member Author

alexeagle commented Jan 17, 2024

Adding some print debugging shows that the module extension isn't executed the way we thought. We call npm_translate_lock but it is non-blocking, the module_ctx.read(attr.pnpm_lock) later in extensions.bzl is already evaluated before we write the changed pnpm-lock.yaml back to the disk. I think this is fixable, but I'm not exactly sure how, and anyway I don't think we have time to prioritize it right now.

@alexeagle alexeagle added funding needed Contribute to https://opencollective.com/aspect-build and removed untriaged Requires traige labels Jan 18, 2024
@alexeagle
Copy link
Member Author

Got some design feedback from the Bazel team: https://bazelbuild.slack.com/archives/C014RARENH0/p1705451482052209

@jbedard
Copy link
Member

jbedard commented May 7, 2024

Support for this has been removed (bzlmod and workspace) in 2.x: ffd4583

@jbedard jbedard closed this as completed May 7, 2024
@github-project-automation github-project-automation bot moved this to ✅ Done in Open Source May 7, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Dec 17, 2024
…epository 'npm2'`

In some cases `yarn bazel run @npm2//:sync` will fail in the first run see: aspect-build/rules_js#1445 as a workaround we run a build before.

```
ERROR: An error occurred during the fetch of repository 'npm2':
   Traceback (most recent call last):
        File "/usr/local/google/home/alanagius/.cache/bazel/_bazel_alanagius/2fa837e4c5ce941f68b762e5f8e7dc4d/external/aspect_rules_js/npm/private/npm_translate_lock.bzl", line 112, column 21, in _npm_translate_lock_impl
                fail(msg)
Error in fail:

INFO: pnpm-lock.yaml file updated. Please run your build again.
```
alan-agius4 added a commit to angular/angular-cli that referenced this issue Dec 17, 2024
…epository 'npm2'`

In some cases `yarn bazel run @npm2//:sync` will fail in the first run see: aspect-build/rules_js#1445 as a workaround we run a build before.

```
ERROR: An error occurred during the fetch of repository 'npm2':
   Traceback (most recent call last):
        File "/usr/local/google/home/alanagius/.cache/bazel/_bazel_alanagius/2fa837e4c5ce941f68b762e5f8e7dc4d/external/aspect_rules_js/npm/private/npm_translate_lock.bzl", line 112, column 21, in _npm_translate_lock_impl
                fail(msg)
Error in fail:

INFO: pnpm-lock.yaml file updated. Please run your build again.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working funding needed Contribute to https://opencollective.com/aspect-build
Projects
Status: Done
Development

No branches or pull requests

2 participants