Kibana canvas plugin create problem

I followed this Custom Kibana Canvas Elements and tried to create my Kibana canvas plugin. However, it failed with the message below when I run the yarn kbn bootstrap command.

kibana: $ yarn build:types && node scripts/register_git_hook
x-pack: $ node legacy/plugins/canvas/scripts/storybook --clean
kibana: $ tsc --p tsconfig.types.json
✖ kibana: Kibana should not be run as root.  Use --allow-root to continue.
kibana: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
✖ kibana: error Command failed with exit code 1.

[bootstrap] failed:

Error: Command failed with exit code 1: yarn run kbn:bootstrap
    at makeError (/root/kibana/packages/kbn-pm/dist/index.js:20332:11)
    at handlePromise (/root/kibana/packages/kbn-pm/dist/index.js:19270:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It seems like the problem is that we cannot run yarn as root.Therefore, I modified my command and ran it again:
yarn kbn bootstrap --allow-root
But, I still got the same error message. Could anyone help me to solve this problem?

My environment is CentOS7.5
Kibana development folder is from the Github and switches to the master branch.
Yarn version is 1.21.0.
Nodejs version is v10.15.2.

If there is anything unclear, please let me know. Thank you!

Hi @Cheng-chieh_Lin,

Ideally you should try to not run any Kibana commands with root privileges unless you absolutely have to. In any case it seems we have a bug with --allow-root, would you mind filing the issue at GitHub with Team:Operations label and reference this issue https://github.com/elastic/kibana/pull/21563?

The only temporary workaround I can think of is appending --allow-root to this line:

"kbn:bootstrap": "yarn build:types && node scripts/register_git_hook --allow-root",

Best,
Oleg

Hi Azasypkin

Sorry again,
Even I updated the package.json with the --allow-root, it still not works. Is there any other solution? I will raise this issue later in the Github.

Below is the error message on the console and for your reference. Many thanks.

kibana: $ yarn build:types && node scripts/register_git_hook --allow-root
kibana: $ tsc --p tsconfig.types.json
kibana: Registering Kibana pre-commit git hook...
kibana: fail Kibana pre-commit git hook was not installed as an error occur.
kibana: ERROR Error: ENOENT: no such file or directory, open '/root/kibana/--git-common-dir/hooks/pre-commit'
kibana: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
✖ kibana: error Command failed with exit code 1.

[bootstrap] failed:

Error: Command failed with exit code 1: yarn run kbn:bootstrap
    at makeError (/root/kibana/packages/kbn-pm/dist/index.js:20332:11)
    at handlePromise (/root/kibana/packages/kbn-pm/dist/index.js:19270:26)
    at process._tickCallback (internal/process/next_tick.js:68:7)
error Command failed with exit code 1.

There is something really fancy going on here. You only added --allow-root, right? Does this script works when you run it separately node scripts/register_git_hook or node scripts/register_git_hook --allow-root (with sudo)?

I tried the method you mentioned. And it told me a weird answer below.

[root@localhost kibana]# sudo node scripts/register_git_hook.js --allow-root
Kibana does not support the current Node.js version v8.16.2. Please use Node.js v10.15.2.

It seems like my nodejs version is not correct so I checked for it. However, the system told me that my default version is 10.15.2 and it is as same as the version Kibana required.

[root@localhost kibana]# nvm ls
->     v10.15.2
         system
default -> 10.15.2 (-> v10.15.2)
node -> stable (-> v10.15.2) (default)
stable -> 10.15 (-> v10.15.2) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.2 (-> N/A)
lts/dubnium -> v10.17.0 (-> N/A)
lts/erbium -> v12.13.1 (-> N/A)

Is the building error reason is for my system wrong nodejs version or it is actually an issue? Or any other method I can try? Thank you!

It's definitely an important bit here. You should make sure first that NVM sets the proper node version for the user you run node on behalf of. It's still would be better if you can find a way to not run all these scripts on behalf of root/superuser.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.