You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am now trying to use emsdk/bazel with bzlmod. However, the contents of /bazel seem to not support bzlmod. In more detail, I'm trying to use emsdk using only MODULE.bazel, but it is not working well.
Is there a way to use emsdk with MODULE.bazel not WORKSPACE?
ERROR: Skipping '//includes:libgfm2pst-wasm.js': error loading package 'includes': Unable to find package for
@@[unknown repo 'emsdk' requested from @@]//emscripten_toolchain:wasm_rules.bzl: The repository '@@
[unknown repo 'emsdk' requested from @@]' could not be resolved: No repository visible as '@emsdk' from
main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in
Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
ERROR: error loading package 'includes': Unable to find package for @@[unknown repo 'emsdk' requested from
@@]//emscripten_toolchain:wasm_rules.bzl: The repository '@@[unknown repo 'emsdk' requested from @@]'
could not be resolved: No repository visible as '@emsdk' from main repository. Was the repository introduced in
WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9
(late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
Reacted by Vertexwahn, Gaetan de Villele and Li-Yu Yu
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:hello-world-wasm': error loading package '': Unable to find package for @@[unknown repo 'emsdk' requested from @@]//emscripten_toolchain:wasm_rules.bzl: The repository '@@[unknown repo 'emsdk' requested from @@]' could not be resolved: No repository visible as '@emsdk' from main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
ERROR: error loading package '': Unable to find package for @@[unknown repo 'emsdk' requested from @@]//emscripten_toolchain:wasm_rules.bzl: The repository '@@[unknown repo 'emsdk' requested from @@]' could not be resolved: No repository visible as '@emsdk' from main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
In theory you could use that, but I didn't even look into fixing the tests, any other host platform than linux and this would break all existing users that don't use bzlmod right now, if merged upstream.
I think it isn't too much work to implement this more properly and would be highly beneficial, given that Bazel now doesn't build without it anymore by default. As this is a free time project I don't have much time, but I could probably look into it soon.
Before that, it would be good to get some opinions how to proceed though.
General strategy
We have two options:
Migrate everything to bzlmod and remove WORKSPACE support in one go. That makes things easy and can probably be reached quickly. However it would require all users to change how they import emsdk when they update it the next time. Given that Bazel is already disabling WORKSPACE support by default, this might actually be ok?
We could give users more time to migrate by supporting both for some time. That needs a little bit of extra work and possibly leads to some code duplication.
Is there any policy on this and what do other users think?
I am leaning towards option 1, because users will have to migrate to bzlmod probably within this year anyway and most people only do it when they have to. We could make it slightly easier by also making emsdk available through the bazel central registry. On the other hand I am biased, because this saves me work.
Implementation
I think it is roughly:
Add a bunch of deps to MODULE.bazel
Convert the deps.bzl and emscripten_deps.bzl files to module extensions
Fix a bunch of bugs that occur, because the repository names are different now and were hardcoded where they shouldn't be
There is a small design question about how to represent custom emscripten cache settings, but I think there are some nice ways to do it with tags on the module extensions. My prototype should allow a syntax like this:
These can be specified multiple times (also across different bazel modules) and will get joined together before creating the cache. Any thoughts on this?
Reacted by xalteropsx, Damian, Gaetan de Villele and Li-Yu Yu
I support option 1 here: Migrate everything to bzlmod and remove WORKSPACE support in one go. As sbc100 said, bazel support in emsdk is best effort. I'm happy to review and merge changes that update emsdk to bzlmod. However, I will ask that we keep the mac and windows versions working; hopefully this does not add too much complexity.
Activity
sbc100 commentedon Jan 9, 2025
@walkingeyerobot ?
[-]Is there a way to emsdk using bzlmod?[/-][+]Is there a way to use emsdk using bzlmod?[/+]Vertexwahn commentedon Jan 17, 2025
https://github.com/emscripten-core/emsdk/blob/main/bazel/deps.bzl can be replaced by adding to the
MODULE.bazelfile:next stop https://github.com/emscripten-core/emsdk/blob/main/bazel/emscripten_deps.bzl
Maybe we can do an incremental migration here...?
ShapeLayer commentedon Jan 20, 2025
Add: I want to know if there is an official manual, procedure, or works in progress about migration to bzlmod.
I've been trying to migrate, and it seems to be increasing works. So I want to check other answers before going any further.
sbc100 commentedon Jan 20, 2025
No plans that I know off. I have no idea what bzlmod even is though.
The bazel support for emsdk it mostly a best effort by interested parties so if you would like to contribute please go ahead.
xalteropsx commentedon Jan 24, 2025
same error
WARNING: Target pattern parsing failed.
ERROR: Skipping '//:hello-world-wasm': error loading package '': Unable to find package for @@[unknown repo 'emsdk' requested from @@]//emscripten_toolchain:wasm_rules.bzl: The repository '@@[unknown repo 'emsdk' requested from @@]' could not be resolved: No repository visible as '@emsdk' from main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
ERROR: error loading package '': Unable to find package for @@[unknown repo 'emsdk' requested from @@]//emscripten_toolchain:wasm_rules.bzl: The repository '@@[unknown repo 'emsdk' requested from @@]' could not be resolved: No repository visible as '@emsdk' from main repository. Was the repository introduced in WORKSPACE? The WORKSPACE file is disabled by default in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025), please migrate to Bzlmod. See https://bazel.build/external/migration.
cburchert commentedon Jan 31, 2025
I was also hit by this, so I spent some time investigating. I hacked through emsdk to make it work and can build my project with my emsdk fork now with pure bzlmod, here is the fork: https://github.com/cburchert/emsdk/tree/main/bazel
In theory you could use that, but I didn't even look into fixing the tests, any other host platform than linux and this would break all existing users that don't use bzlmod right now, if merged upstream.
I think it isn't too much work to implement this more properly and would be highly beneficial, given that Bazel now doesn't build without it anymore by default. As this is a free time project I don't have much time, but I could probably look into it soon.
Before that, it would be good to get some opinions how to proceed though.
General strategy
We have two options:
Migrate everything to bzlmod and remove WORKSPACE support in one go. That makes things easy and can probably be reached quickly. However it would require all users to change how they import emsdk when they update it the next time. Given that Bazel is already disabling WORKSPACE support by default, this might actually be ok?
We could give users more time to migrate by supporting both for some time. That needs a little bit of extra work and possibly leads to some code duplication.
Is there any policy on this and what do other users think?
I am leaning towards option 1, because users will have to migrate to bzlmod probably within this year anyway and most people only do it when they have to. We could make it slightly easier by also making emsdk available through the bazel central registry. On the other hand I am biased, because this saves me work.
Implementation
I think it is roughly:
There is a small design question about how to represent custom emscripten cache settings, but I think there are some nice ways to do it with tags on the module extensions. My prototype should allow a syntax like this:
These can be specified multiple times (also across different bazel modules) and will get joined together before creating the cache. Any thoughts on this?
xalteropsx commentedon Jan 31, 2025
will check soon thnx for sharing it bro
walkingeyerobot commentedon Feb 3, 2025
I support option 1 here: Migrate everything to bzlmod and remove WORKSPACE support in one go. As sbc100 said, bazel support in emsdk is best effort. I'm happy to review and merge changes that update emsdk to bzlmod. However, I will ask that we keep the mac and windows versions working; hopefully this does not add too much complexity.
Bazel: Pass nodejs binary path as an environment variable. (#1518)
Bazel: Migrate to bzlmod (#1530)
Bazel: Pass nodejs binary path as an environment variable. (emscripte…
Bazel: Migrate to bzlmod (emscripten-core#1530)