Package 'build-essential' has no installation candidate

While writing some packer scripts recently to build an EC2 AMI (Ubuntu 14.04 x64), I was intermittently getting the following error:

amazon-ebs: Package build-essential is not available, but is referred to by another package.
amazon-ebs: This may mean that the package is missing, has been obsoleted, or
amazon-ebs: is only available from another source
amazon-ebs:
amazon-ebs: E: Package 'build-essential' has no installation candidate

Because it was intermittent I struggled to find a solution; all the posts online suggested I should run apt-get update (or variants) or that I should change the /etc/apt/sources.list file; none worked.

Eventually I realised there was an error when the box booted regarding the default locale. Running the command:

sudo locale-gen en_GB.UTF-8

before any subsequent apt-get update, apt-get install commands; appears to have corrected the problem (95% of the time).

(Picture: Lunchtime atop a Skyscraper, by Charles C. Ebbets)

Ben Squire

Read more posts by this author.

Leicestershire, United Kingdom https://squired.co.uk