tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Wasm Backend Bazel Build Error: workspace() got unexpected keyword argument 'managed_directories'

Open csAugust opened this issue 1 year ago • 3 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • Bazel Version: bazel 7.0.1
  • Yarn Version: v1.22.19

Describe the problem

Steps that are executed before running into the problem: cd tfjs-backend-wasm && yarn build Then I get an error which seems like workspace() in file tfjs/WORKSPACE got unexpected keyword argument.

Any other info / logs

(base) PS D:\Courses\github_library\tfjs\tfjs-backend-wasm> yarn build
yarn run v1.22.19
$ bazel build -c opt :tfjs-backend-wasm_pkg
Starting local Bazel server and connecting to it...
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to https://github.com/bazelbuild/bazel/issues/18958.
ERROR: Traceback (most recent call last):
        File "D:/courses/github_library/tfjs/WORKSPACE", line 16, column 10, in <toplevel>
                workspace(
Error in workspace: workspace() got unexpected keyword argument 'managed_directories'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'workspace.bzl': no such package '@@bazel_skylib//': error loading package 'external': Could not load //external package
Computing main repo mapping:
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I have tried to naively delete this keyword argument in workspace() call in file tfjs/WORKSPACE, i.e.

workspace(
    name = "tfjs",
)

I got another error:

(base) PS D:\Courses\github_library\tfjs\tfjs-backend-wasm> yarn build
yarn run v1.22.19
$ bazel build -c opt :tfjs-backend-wasm_pkg
INFO: Analyzed target //tfjs-backend-wasm:tfjs-backend-wasm_pkg (2 packages loaded, 52 targets configured).
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/LICENSE.md'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/README.md'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/bin/rollup'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/es/package.json'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/es/rollup.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/es/shared/node-entry.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/es/shared/watch.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/loadConfigFile.d.ts'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/loadConfigFile.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/rollup.d.ts'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/rollup.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/fsevents-importer.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/index.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/loadConfigFile.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/rollup.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/watch-cli.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/watch-proxy.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/dist/shared/watch.js'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: missing input file '@@npm//:node_modules/rollup/package.json'
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14: Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: 19 input file(s) do not exist
Target //tfjs-backend-wasm:tfjs-backend-wasm_pkg failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: C:/users/czy/_bazel_czy/2v2rfsni/external/npm/rollup/bin/BUILD.bazel:9:14 Middleman _middlemen/external_Snpm_Srollup_Sbin_Srollup.bat-runfiles failed: 19 input file(s) do not exist
INFO: Elapsed time: 1.620s, Critical Path: 0.06s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Could anyone please help me out? Thanks a lot.

csAugust avatar Jan 30 '24 09:01 csAugust

Hi, @csAugust

Thank you for bringing this issue to our attention and I tried on my MacOS M1 system and it's working as expected with Bazel 5.3.0 version so could you please give it try with Bazel version 5.3.0 on your Windows 10 system and see is it working as expected or not ? Meanwhile I'll also try from my end on Windows 10 system and will update you soon.

Thank you for your cooperation and patience.

Here is output log on MacOS M1 system :

(base) gaikwadrahul-macbookpro:tfjs-backend-wasm gaikwadrahul$ yarn build
yarn run v1.22.21
warning ../../../../../package.json: No license field
$ bazel build -c opt :tfjs-backend-wasm_pkg
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Analyzed target //tfjs-backend-wasm:tfjs-backend-wasm_pkg (281 packages loaded, 18858 targets configured).
INFO: Found 1 target...
INFO: From Linking tfjs-backend-wasm/src/cc/tfjs-backend-wasm-threaded-simd.js:
emcc: warning: USE_PTHREADS + ALLOW_MEMORY_GROWTH may run non-wasm code slowly, see https://github.com/WebAssembly/design/issues/1271 [-Wpthreads-mem-growth]
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.fesm.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.fesm.js...
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.fesm.js in 7.6s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.es2017.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.es2017.js...
No name was provided for external module "os" in "output.globals" – guessing "require$$4".
Creating a browser bundle that depends on Node.js built-in modules ("fs", "path", "perf_hooks" and "os"). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.es2017.js in 8.4s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.fesm.min.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.fesm.min.js...
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.fesm.min.js in 10.9s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.es2017.min.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.es2017.min.js...
No name was provided for external module "os" in "output.globals" – guessing "require$$4".
Creating a browser bundle that depends on Node.js built-in modules ("fs", "path", "perf_hooks" and "os"). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.es2017.min.js in 11.4s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm-miniprogram.min.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm-miniprogram.min.js...
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm-miniprogram.min.js in 10.7s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.min.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.min.js...
No name was provided for external module "os" in "output.globals" – guessing "require$$4".
Creating a browser bundle that depends on Node.js built-in modules ("fs", "path", "perf_hooks" and "os"). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.min.js in 14.5s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.js...
No name was provided for external module "os" in "output.globals" – guessing "require$$4".
Creating a browser bundle that depends on Node.js built-in modules ("fs", "path", "perf_hooks" and "os"). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.js in 15s
INFO: From Bundling JavaScript tfjs-backend-wasm/tf-backend-wasm.node.js [rollup]:

bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/src/index.mjs → bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.node.js...
created bazel-out/darwin_arm64-opt/bin/tfjs-backend-wasm/tf-backend-wasm.node.js in 15.1s
Target //tfjs-backend-wasm:tfjs-backend-wasm_pkg up-to-date:
  dist/bin/tfjs-backend-wasm/tfjs-backend-wasm_pkg
INFO: Elapsed time: 1974.555s, Critical Path: 83.84s
INFO: 5457 processes: 902 internal, 4553 darwin-sandbox, 2 local.
INFO: Build completed successfully, 5457 total actions
✨  Done in 1975.64s.
(base) gaikwadrahul-macbookpro:tfjs-backend-wasm gaikwadrahul$ bazel --version
bazel 5.3.0
(base) gaikwadrahul-macbookpro:tfjs-backend-wasm gaikwadrahul$ 

gaikwadrahul8 avatar Jan 30 '24 15:01 gaikwadrahul8

Hi, @csAugust

I tried to replicate the same issue from my end on Windows 10 system with Bazel version 7.0.2 and I'm also getting the similar error which you've mentioned in the issue template so we'll have to dig more into this issue and will update you soon, thank you for bringing this issue to our attention. Thank you.

For reference I have added output log below with Bazel version 7.0.2 :

PS C:\Users\gaikwadrahul\Desktop\test-8160\tfjs\tfjs-backend-wasm> yarn build
yarn run v1.22.21
warning ..\..\..\..\package.json: No license field
$ bazel build -c opt :tfjs-backend-wasm_pkg
ERROR: Traceback (most recent call last):
        File "C:/users/gaikwadrahul/desktop/test-8160/tfjs/WORKSPACE", line 16, column 10, in <toplevel>
                workspace(
Error in workspace: workspace() got unexpected keyword argument 'managed_directories'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'workspace.bzl': no such package '@@bazel_skylib//': error loading package 'external': Could not load //external package
Computing main repo mapping:
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS C:\Users\gaikwadrahul\Desktop\test-8160\tfjs\tfjs-backend-wasm> bazel --version
bazel 7.0.2
PS C:\Users\gaikwadrahul\Desktop\test-8160\tfjs\tfjs-backend-wasm> 

gaikwadrahul8 avatar Jan 31 '24 17:01 gaikwadrahul8

Hi, @csAugust

I tried to replicate the same issue from my end on Windows 10 system with Bazel version 7.0.2 and I'm also getting the similar error which you've mentioned in the issue template so we'll have to dig more into this issue and will update you soon, thank you for bringing this issue to our attention. Thank you.

For reference I have added output log below with Bazel version 7.0.2 :

PS C:\Users\gaikwadrahul\Desktop\test-8160\tfjs\tfjs-backend-wasm> yarn build
yarn run v1.22.21
warning ..\..\..\..\package.json: No license field
$ bazel build -c opt :tfjs-backend-wasm_pkg
ERROR: Traceback (most recent call last):
        File "C:/users/gaikwadrahul/desktop/test-8160/tfjs/WORKSPACE", line 16, column 10, in <toplevel>
                workspace(
Error in workspace: workspace() got unexpected keyword argument 'managed_directories'
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'workspace.bzl': no such package '@@bazel_skylib//': error loading package 'external': Could not load //external package
Computing main repo mapping:
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS C:\Users\gaikwadrahul\Desktop\test-8160\tfjs\tfjs-backend-wasm> bazel --version
bazel 7.0.2
PS C:\Users\gaikwadrahul\Desktop\test-8160\tfjs\tfjs-backend-wasm> 

Thank you for your answer! I'm sorry that I haven't replied you in time. It's very helpful since I get no such error once I use bazel 5.3.0. Thanks!

csAugust avatar Feb 05 '24 14:02 csAugust

Hi, @csAugust

I apologize for the delayed response. We're glad to hear that your issue has been resolved using Bazel version 5.3.0. If everything is working as expected, please feel free to close this issue. If you need any further assistance please feel to create new issue.

Thank you for your cooperation and patience.

gaikwadrahul8 avatar Mar 22 '24 12:03 gaikwadrahul8

Hi, @csAugust

We have not got any confirmation from your end so now I'm closing this issue as issue has been resolved using Bazel version 5.3.0 and If you need any further assistance please feel to create new issue we would be glad to help you further.

Thank you for your cooperation and patience.

gaikwadrahul8 avatar Mar 23 '24 09:03 gaikwadrahul8

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Mar 23 '24 09:03 google-ml-butler[bot]

When I use Bazel version 6.0.0 and upper, error is 26.73 ERROR: Traceback (most recent call last): 26.73 File "/src/onos/WORKSPACE", line 1, column 10, in 26.73 workspace( 26.73 Error in workspace: workspace() got unexpected keyword argument 'managed_directories' 26.92 ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'tools/build_defs/repo/http.bzl': no such package '@bazel_tools//tools/build_defs/repo': error loading package 'external': Could not load //external package

Xiao-Fei-fft avatar Apr 08 '24 12:04 Xiao-Fei-fft

But when I use Bazel version 5.4.1 and lower , error is INFO: Repository bazel_skylib instantiated at: 91.87 /src/onos/WORKSPACE:23:13: in 91.87 Repository rule http_archive defined at: 91.87 /root/.cache/bazel/_bazel_root/0aa863e14c5fcdf45a1e32e8876d9bd8/external/bazel_tools/tools/build_defs/repo/http.bzl:355:31: in 91.89 WARNING: Download from https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz failed: class java.io.IOException connect timed out 91.89 ERROR: An error occurred during the fetch of repository 'bazel_skylib': 91.89 Traceback (most recent call last): 91.89 File "/root/.cache/bazel/_bazel_root/0aa863e14c5fcdf45a1e32e8876d9bd8/external/bazel_tools/tools/build_defs/repo/http.bzl", line 125, column 45, in _http_archive_impl 91.89 download_info = ctx.download_and_extract( 91.89 Error in download_and_extract: java.io.IOException: Error downloading [https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz] to /root/.cache/bazel/_bazel_root/0aa863e14c5fcdf45a1e32e8876d9bd8/external/bazel_skylib/temp5896115683444481798/bazel-skylib-1.0.2.tar.gz: connect timed out 91.89 ERROR: /src/onos/WORKSPACE:23:13: fetching http_archive rule //external:bazel_skylib: Traceback (most recent call last): 91.89 File "/root/.cache/bazel/_bazel_root/0aa863e14c5fcdf45a1e32e8876d9bd8/external/bazel_tools/tools/build_defs/repo/http.bzl", line 125, column 45, in _http_archive_impl 91.89 download_info = ctx.download_and_extract( 91.89 Error in download_and_extract: java.io.IOException: Error downloading [https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz] to /root/.cache/bazel/_bazel_root/0aa863e14c5fcdf45a1e32e8876d9bd8/external/bazel_skylib/temp5896115683444481798/bazel-skylib-1.0.2.tar.gz: connect timed out 91.91 ERROR: no such package '@bazel_skylib//': java.io.IOException: Error downloading [https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz] to /root/.cache/bazel/_bazel_root/0aa863e14c5fcdf45a1e32e8876d9bd8/external/bazel_skylib/temp5896115683444481798/bazel-skylib-1.0.2.tar.gz: connect timed out 91.99 INFO: Elapsed time: 86.251s 91.99 INFO: 0 processes. 91.99 FAILED: Build did NOT complete successfully (0 packages loaded) 92.00 FAILED: Build did NOT complete successfully (0 packages loaded)

Dockerfile:68

Xiao-Fei-fft avatar Apr 08 '24 13:04 Xiao-Fei-fft

@Xiao-Fei-fft : It worked for me. Check that you are not behind a firewall.

In between thanks @gaikwadrahul8 for suggesting to use the version 5.3.0. Its failing for versions 6.0.0 and 7.1.2 with the error Error in workspace: workspace() got unexpected keyword argument 'managed_directories'

rahul-sharma-78 avatar May 09 '24 22:05 rahul-sharma-78