Yarn kbn bootstrap fails, A few "Permission denied" errors occurred!

hi, i fork the kibana respository and pull it from GitHub,and then try to build kibana on windows10 with WSL2.
I referred to the document : Kibana Guide.(8.15).
My environment:
Linux WIN-20230627BHI 5.15.153.1-microsoft-standard-WSL2
图片

I build it with root, and the error details are as follows:

root@WIN-20230627BHI:/home/hash-yang/kibana# yarn kbn bootstrap --allow-root
yarn run v1.22.22
$ node scripts/kbn bootstrap --allow-root
[bazel] INFO: Invocation ID: 619a06ec-ed8d-49c7-87c6-856f82e369c0
[bazel] INFO: Analyzed 3 targets (1 packages loaded, 7 targets configured).
[bazel] INFO: Found 3 targets...
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-esql-ast/BUILD.bazel:27:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-esql-ast/src/ast/helpers.ts bazel-out/k8-fastbuild/bin/packages/kbn-esql-ast/src/ast/helpers.ts
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-esql-ast/src/ast/helpers.ts': Permission denied
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-i18n/BUILD.bazel:32:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-i18n/package.json bazel-out/k8-fastbuild/bin/packages/kbn-i18n/package.json
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-i18n/package.json': Permission denied
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-esql-ast/BUILD.bazel:27:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-esql-ast/src/types.ts bazel-out/k8-fastbuild/bin/packages/kbn-esql-ast/src/types.ts
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-esql-ast/src/types.ts': Permission denied
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-esql-ast/BUILD.bazel:27:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-esql-ast/src/ast_factory.ts bazel-out/k8-fastbuild/bin/packages/kbn-esql-ast/src/ast_factory.ts
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-esql-ast/src/ast_factory.ts': Permission denied
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-esql-ast/BUILD.bazel:27:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-esql-ast/src/ast/constants.ts bazel-out/k8-fastbuild/bin/packages/kbn-esql-ast/src/ast/constants.ts
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-esql-ast/src/ast/constants.ts': Permission denied
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-esql-validation-autocomplete/BUILD.bazel:28:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-esql-validation-autocomplete/package.json bazel-out/k8-fastbuild/bin/packages/kbn-esql-validation-autocomplete/package.json
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-esql-validation-autocomplete/package.json': Permission denied
[bazel] ERROR: /home/hash-yang/kibana/packages/kbn-esql-ast/BUILD.bazel:27:11: Copying file failed: (Exit 1): bash failed: error executing command /bin/bash -c 'cp -f "$1" "$2"' '' packages/kbn-esql-ast/src/visitor/types.ts bazel-out/k8-fastbuild/bin/packages/kbn-esql-ast/src/visitor/types.ts
[bazel] 
[bazel] Use --sandbox_debug to see verbose messages from the sandbox
[bazel] cp: cannot stat 'packages/kbn-esql-ast/src/visitor/types.ts': Permission denied
[bazel] INFO: Elapsed time: 5.006s, Critical Path: 0.27s
[bazel] INFO: 8 processes: 8 internal.
[bazel] 
 HINT 
 HINT If experiencing problems with node_modules try `yarn kbn bootstrap --force-install` or as last resort `yarn kbn reset && yarn kbn bootstrap`
 HINT 
 ERROR  [bootstrap] failed: [bazel] exited with code [1]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

it seems that all the errors are occurred in 'packages' directory. I tried to change all the files and directories mode to 777, but it doesn't work.

It was resolved a few days ago. Please do not use the Root role for building; instead, follow the guidelines and use a regular role for this task.

1 Like

Thanks for sharing your solution, @hash-yang.