Install of apt package is failing

Hi. I'm just getting started with elastic and am having an issue installing the package from the apt repo. Here's the output:

Fri 28 Sep 19:24:00
root@elastic [~]

sudo apt-get update && sudo apt-get install elasticsearch

Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Ign:3 https://artifacts.elastic.co/packages/6.x/apt stable InRelease
Get:4 https://artifacts.elastic.co/packages/6.x/apt stable Release [4,360 B]
Get:5 https://artifacts.elastic.co/packages/6.x/apt stable Release.gpg [473 B]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:7 https://artifacts.elastic.co/packages/6.x/apt stable/main amd64 Packages [27.0 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [388 kB]
Fetched 591 kB in 1s (397 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
elasticsearch
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 97.9 MB of archives.
After this operation, 151 MB of additional disk space will be used.
Get:1 https://artifacts.elastic.co/packages/6.x/apt stable/main amd64 elasticsearch all 6.4.1 [97.9 MB]
Fetched 97.9 MB in 5s (20.8 MB/s)
Selecting previously unselected package elasticsearch.
(Reading database ... 102199 files and directories currently installed.)
Preparing to unpack .../elasticsearch_6.4.1_all.deb ...
dpkg: error processing archive /var/cache/apt/archives/elasticsearch_6.4.1_all.deb (--unpack):
new elasticsearch package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/elasticsearch_6.4.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

This is a dedicated ubuntu 18.04.1 KVM VM that I just spun up and has plenty of space storage so that's not the issue:

df -h /var

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv 115G 2.1G 113G 2% /

Any suggestions would be greatly appreciated!

OK, I found what the problem is. I extracted the .deb and in DEBIAN/preinst, if it doesn't find java, it just exits with an error code of 1 (the 'echo' statements are never displayed, the install just fails).

I added 'default-jre' to the Depends line of DEBIAN/control:

Depends: bash, libc6, adduser, coreutils, default-jre

Then rebuilt the .deb. It installs successfully if the default-jre package is already installed and installs it as a dependency if it's not:

apt-get install ./elasticsearch-6.4.1-mine.deb

Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'elasticsearch' instead of './elasticsearch-6.4.1-mine.deb'
The following additional packages will be installed:
default-jre
Suggested packages:
default-java-plugin
The following NEW packages will be installed:
default-jre elasticsearch
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,092 B/82.4 MB of archives.
After this operation, 151 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 default-jre amd64 2:1.10-63ubuntu1~02 [1,092 B]
Get:2 /tmp/elasticsearch-6.4.1-mine.deb elasticsearch all 6.4.1 [82.4 MB]
Fetched 1,092 B in 1s (867 B/s)
Selecting previously unselected package default-jre.
(Reading database ... 116894 files and directories currently installed.)
Preparing to unpack .../default-jre_2%3a1.10-63ubuntu1~02_amd64.deb ...
Unpacking default-jre (2:1.10-63ubuntu1~02) ...
Selecting previously unselected package elasticsearch.
Preparing to unpack /tmp/elasticsearch-6.4.1-mine.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (6.4.1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Setting up default-jre (2:1.10-63ubuntu1~02) ...
Setting up elasticsearch (6.4.1) ...
Created elasticsearch keystore in /etc/elasticsearch
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for ureadahead (0.100.0-20) ...

I know you probably don't want to necessarily lock users into using the default-jre package but if they're going through the trouble of installing the elasticsearch package from the repo, that's probably what they'll want to install anyway.

Cheers

Thanks for reporting this. We are aware of the issue and plan to do something about it. See the comments in https://github.com/elastic/elasticsearch/issues/31845

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