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]: npm_translate_lock's update_pnpm_lock attribute + bzlmod errors on first build when used with external repositories (eg. rules_ts) #1371

Closed
Wito-1 opened this issue Nov 21, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Wito-1
Copy link

Wito-1 commented Nov 21, 2023

What happened?

I'm trying out rules_js's npm.translate_lock() with update_pnpm_lock working with with rules_ts()+ bzlmod

I'm finding that the first time I try to execute something like bazel build //... with a blank pnpm-lock.yaml file, the pnpm-lock.yaml file gets updated, but then the BUILD.bazel file isn't able to resolve the generated node_modules label.

BUILD.bazel:3:10: error loading package '': at /home/juan/.cache/bazel/_bazel_juan/99e149c4525c8cdc2b7c19f1841583fd/external/aspect_rules_js~override~npm~npm/defs.bzl:5:6: 
Unable to find package for @aspect_rules_js~override~npm~npm__at_ampproject_remapping__2.2.1__links//:defs.bzl: The 
repository '@aspect_rules_js~override~npm~npm__at_ampproject_remapping__2.2.1__links' could not be resolved: Repository
'@aspect_rules_js~override~npm~npm__at_ampproject_remapping__2.2.1__links' is not defined. and referenced by
'//:hello_world_ts_tsconfig'

On subsequent executions or if there's no need to update the pnpm-lock file, everything is able to resolve & build successfully.

I also tested this using an e2e example in the rules_ts repository and see the same result:

juan@juan-XPS-9315:~/rules_ts/e2e/bzlmod$ git diff
diff --git a/e2e/bzlmod/MODULE.bazel b/e2e/bzlmod/MODULE.bazel
index 7215263..3656ab8 100644
--- a/e2e/bzlmod/MODULE.bazel
+++ b/e2e/bzlmod/MODULE.bazel
@@ -23,6 +23,8 @@ npm = use_extension(
 npm.npm_translate_lock(
     name = "npm",
     pnpm_lock = "//:pnpm-lock.yaml",
+    update_pnpm_lock = True,
+    data = ["//:package.json"],
 )
 use_repo(npm, "npm")

The failing output and subsequent execution passing output (no changes in between):

juan@juan-XPS-9315:~/rules_ts/e2e/bzlmod$ bazel build //...
WARNING: For repository 'bazel_skylib', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph.
ERROR: Skipping '//...': error loading package under directory '': error loading package '': at /home/juan/.cache/bazel/_bazel_juan/93cbb89bc7b7e5a7e995291e864e189e/external/aspect_rules_js~1.34.0~npm~npm/defs.bzl:7:6: Unable to find package for @aspect_rules_js~1.34.0~npm~npm__at_bufbuild_protoplugin__1.3.0__links//:defs.bzl: The repository '@aspect_rules_js~1.34.0~npm~npm__at_bufbuild_protoplugin__1.3.0__links' could not be resolved: Repository '@aspect_rules_js~1.34.0~npm~npm__at_bufbuild_protoplugin__1.3.0__links' is not defined.
WARNING: Target pattern parsing failed.
ERROR: error loading package under directory '': error loading package '': at /home/juan/.cache/bazel/_bazel_juan/93cbb89bc7b7e5a7e995291e864e189e/external/aspect_rules_js~1.34.0~npm~npm/defs.bzl:7:6: Unable to find package for @aspect_rules_js~1.34.0~npm~npm__at_bufbuild_protoplugin__1.3.0__links//:defs.bzl: The repository '@aspect_rules_js~1.34.0~npm~npm__at_bufbuild_protoplugin__1.3.0__links' could not be resolved: Repository '@aspect_rules_js~1.34.0~npm~npm__at_bufbuild_protoplugin__1.3.0__links' is not defined.
INFO: Elapsed time: 1.489s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading: 



juan@juan-XPS-9315:~/rules_ts/e2e/bzlmod$ bazel build //...
WARNING: For repository 'bazel_skylib', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph.
INFO: Analyzed 7 targets (9 packages loaded, 84 targets configured).
INFO: Found 7 targets...
INFO: From Compiling src/google/protobuf/message_lite.cc [for tool]:
In file included from /usr/include/string.h:535,
                 from external/protobuf~21.7/src/google/protobuf/stubs/port.h:39,
                 from external/protobuf~21.7/src/google/protobuf/stubs/common.h:48,
                 from external/protobuf~21.7/src/google/protobuf/message_lite.h:46,
                 from external/protobuf~21.7/src/google/protobuf/message_lite.cc:36:
In function 'void* memcpy(void*, const void*, size_t)',
    inlined from 'uint8_t* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, uint8_t*)' at external/protobuf~21.7/src/google/protobuf/io/coded_stream.h:684:16,
    inlined from 'virtual uint8_t* google::protobuf::internal::ImplicitWeakMessage::_InternalSerialize(uint8_t*, google::protobuf::io::EpsCopyOutputStream*) const' at external/protobuf~21.7/src/google/protobuf/implicit_weak_message.h:103:28,
    inlined from 'bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const' at external/protobuf~21.7/src/google/protobuf/message_lite.cc:411:30:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: warning: 'void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
INFO: Elapsed time: 34.200s, Critical Path: 18.61s
INFO: 131 processes: 1 internal, 130 linux-sandbox.
INFO: Build completed successfully, 131 total actions

Version

Development (host) and target OS/architectures:

Output of bazel --version: bazel 6.3.2

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_bazel_lib", version = "1.38.1")
bazel_dep(name = "aspect_rules_js", version = "1.34.0")
bazel_dep(name = "aspect_rules_ts", version = "2.1.0")

Language(s) and/or frameworks involved:
TS

How to reproduce

This can be reproduced by:
1. Cloning the rules_ts repo and navigating to the e2e/bzlmod dir:

git clone https://github.com/aspect-build/rules_ts.git && cd rules_ts/e2e/bzlmod
  1. make the following modifications to the rules_ts repository:
juan@juan-XPS-9315:~/rules_ts/e2e/bzlmod$ git diff
diff --git a/e2e/bzlmod/MODULE.bazel b/e2e/bzlmod/MODULE.bazel
index 7215263..3656ab8 100644
--- a/e2e/bzlmod/MODULE.bazel
+++ b/e2e/bzlmod/MODULE.bazel
@@ -23,6 +23,8 @@ npm = use_extension(
 npm.npm_translate_lock(
     name = "npm",
     pnpm_lock = "//:pnpm-lock.yaml",
+    update_pnpm_lock = True,
+    data = ["//:package.json"],
 )
 use_repo(npm, "npm")
  1. clear the contents of the pnpm-lock.yaml file:
echo "" > pnpm-lock.yaml
  1. build
bazel build //...


### Any other information?

_No response_
@Wito-1 Wito-1 added the bug Something isn't working label Nov 21, 2023
@github-actions github-actions bot added the untriaged Requires traige label Nov 21, 2023
@gregmagolan gregmagolan moved this to On Deck in Open Source Nov 27, 2023
@gregmagolan gregmagolan removed the untriaged Requires traige label Nov 27, 2023
@gregmagolan gregmagolan self-assigned this Nov 27, 2023
@gregmagolan
Copy link
Member

@jbedard I think your recent change resolved this issue?

@jbedard
Copy link
Member

jbedard commented Jan 22, 2024

83ceefd adds a warning explaining the issue but I don't think we can actually fix this.

I think #1445 is actually a dupe of this issue but I'm going to close this one since the #1445 URL is in the error message presented to the user.

@jbedard jbedard closed this as completed Jan 22, 2024
@github-project-automation github-project-automation bot moved this from On Deck to ✅ Done in Open Source Jan 22, 2024
@gregmagolan gregmagolan removed their assignment Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants