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
js_library
exports using package_path
don't seem to work from external workspaces.
#3479
Comments
An additional discovery: including any source file from an external repository in
INFO: Analyzed target //:bin2 (2 packages loaded, 4 targets configured).
INFO: Found 1 target...
Target //:bin2 up-to-date:
bazel-bin/bin2.sh
bazel-bin/bin2_loader.cjs
bazel-bin/bin2_require_patch.cjs
INFO: Elapsed time: 0.209s, Critical Path: 0.01s
INFO: 7 processes: 7 internal.
INFO: Build completed successfully, 7 total actions
INFO: Build completed successfully, 7 total actions
Error: Cannot find module '@ext/ws/lib'
Require stack:
- /home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin2.sh.runfiles/main_ws/bin.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (bin.js:1:13)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159: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:77:12) If we inspect the execroot here, we can see that the module is created, but # Execroot from a run of `@main_ws//:bin2
$ find -L /home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/ | grep node_modules
find: File system loop detected; ‘/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws/bin.sh.runfiles’ is part of the same file system loop as ‘/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/’.
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws/bin_loader.cjs
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws/bin_require_patch.cjs
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws/bin.sh
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws/_bin.module_mappings.json
/home/pras/.cache/bazel/_bazel_pras/df2aff05c573141092662ae5db828664/execroot/main_ws/bazel-out/k8-fastbuild/bin/bin.sh.runfiles/main_ws/node_modules/@ext/ws/bin.sh.runfiles_manifest |
This issue has been automatically marked as stale because it has not had any activity for 6 months. It will be closed if no further activity occurs in 30 days. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs! |
This issue was automatically closed because it went 30 days without any activity since it was labeled "Can Close?" |
🐞 bug report
Affected Rule
This issue is probably either in:
js_library
nodejs_binary
Is this a regression?
Not sure, I did not immediately find a working older version.
Description
The
package_path
directive seems to only work on references within the same repository, and does not work when the same library is referenced externally.Suppose there are two workspaces,
ext_ws
andmain_ws
. Inext_ws
a simplejs_library
is defined with apackage_path="@ext_ws/foo"
and can be imported bynodejs_binary
targets within the workspace usingimport foo from "@ext_ws/foo"
.However, this fails to work when the same library is referenced from a
nodejs_library
in another workspace,main_ws
, that is loadingext_ws
. Note that this target can contains identical source code and BUILD definition to the target inext_ws
that works.🔬 Minimal Reproduction
https://github.com/psigen/rules_nodejs-issue-3479
🔥 Exception or Error
Instead of importing successfully, running the affected code returns a generic import failure:
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules_nodejs version:
(Please check that you have matching versions between WORKSPACE file and
@bazel/*
npm packages.)Anything else relevant?
If we compare the execroots in the local vs external workspace cases, we see that a
node_modules
entry is populated in the former case, but only an empty root directory is created in the latter:The text was updated successfully, but these errors were encountered: