Build plugin failing at last stage with ERROR Error: Premature close

Hi Everyone,

As per the documentation : Plugin tooling | Kibana Guide [8.5] | Elastic

Topic : Build plugin distributable
To build your plugin run within your plugin folder:

yarn build

It will output azip archive in kibana/plugins/my_plugin_name/build/ folder.

It is failing with below error :

info [  kibana  ] Creating deb package
info $ fpm --force -t deb --package /Users/sunil/Documents/workspace/kibana/target/NAME-8.5.1-SNAPSHOT-ARCH.TYPE -s dir --name kibana --description Explore and visualize your Elasticsearch data --version 8.5.1-SNAPSHOT --url https://www.elastic.co --vendor Elasticsearch, Inc. --maintainer Kibana Team......... [BIG TEXT]

   │ERROR failure 0 sec
   │ERROR Error: Premature close
   │          at new NodeError (node:internal/errors:387:5)
   │          at Socket.onclose (node:internal/streams/end-of-stream:140:30)
   │          at Socket.emit (node:events:525:35)
   │          at Pipe.<anonymous> (node:net:301:12)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

looking for help.

Hi @Sunil_Jagtap. Have you tried running yarn kbn bootstrap before running yarn build? If that still doesn't work, try running yarn kbn clean && yarn kbn bootstrap. Then try yarn build again.

1 Like

Exact same issue. And I did run yarn kbn bootstrap before yarn build.

The following instructions "work" in the sense that they (i.e. --skip-os-packages) disable the debian and distribution level packaging.

#!/usr/bin/env fish
nvm install (cat .nvmrc)
nvm use
corepack enable
yarn kbn bootstrap --force-install
node scripts/build --all-platforms --skip-os-packages

You may also do yarn build --skip-os-packages for the last line.

This error possibly appears because of missing dependencies such as fpm. Dunno.

Edit: This error is indeed due to missing fpm. To install fpm, do the following:

gix clone https://github.com/jordansissel/fpm.git
cd fpm
bundle install
bundle exec gem build fpm.gemspec
gem install fpm-*.gem