Debian – How to resolve dpkg error processing package google-cloud-sdk

aptdebiangoogle-cloud-platform

I chose Debian 9 for my Google Cloud Platform instance and was running
sudo apt update and sudo apt upgrade just fine, till yesterday, after I had installed apache (and nothing else), and made no other system modifications. I usually connect to the virtual machine via SSL and leave the window open for hours, but yesterday, in an attempt to install libopencv-dev by running sudo apt update, sudo apt upgrade and sudo apt install libopencv-dev, I got the following error:

myusername@instance-1:~$ sudo apt update
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://deb.debian.org/debian stretch-updates InRelease [88.5 kB]
Get:3 http://deb.debian.org/debian stretch-backports InRelease [82.9 kB] 
Hit:4 http://deb.debian.org/debian stretch Release                                   
Hit:5 http://security.debian.org stretch/updates InRelease                             
Hit:7 http://packages.cloud.google.com/apt cloud-sdk-stretch InRelease                 
Hit:8 http://packages.cloud.google.com/apt google-cloud-compute-stretch InRelease
Hit:9 http://packages.cloud.google.com/apt google-cloud-packages-archive-keyring-stretch InRelease
Fetched 171 kB in 0s (171 kB/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
myusername@instance-1:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up google-cloud-sdk (162.0.0-0) ...
Killed
dpkg: error processing package google-cloud-sdk (--configure):
 subprocess installed post-installation script returned error exit status 137
E: Sub-process /usr/bin/dpkg returned an error code (1)
myusername@instance-1:~$ 

I sought help from an IRC channel (#debian) and was told that output indicated that the google cloud package (or its repository?) did not exist; however when i run an aptitude search for it, it is present:

myusername@instance-1:~$ sudo apt search google-cloud-sdk
Sorting... Done
Full Text Search... Done
google-cloud-sdk/cloud-sdk-stretch,now 162.0.0-0 all [installed]
  Utilities for the Google Cloud Platform

google-cloud-sdk-app-engine-go/cloud-sdk-stretch 162.0.0-0 amd64
  Go runtime for Google App Engine

google-cloud-sdk-app-engine-java/cloud-sdk-stretch 162.0.0-0 all
  Java runtime for Google App Engine

google-cloud-sdk-app-engine-python/cloud-sdk-stretch 162.0.0-0 all
  Python runtime for Google App Engine

google-cloud-sdk-bigtable-emulator/cloud-sdk-stretch 162.0.0-0 amd64
  Emulator for Google Cloud Bigtable.

google-cloud-sdk-cbt/cloud-sdk-stretch 162.0.0-0 amd64
  Google Cloud Bigtable Command Line Tool

google-cloud-sdk-datalab/cloud-sdk-stretch 162.0.0-0 all
  Command-line utility for Google Cloud Datalab

google-cloud-sdk-datastore-emulator/cloud-sdk-stretch 162.0.0-0 all
  Emulator for Google Cloud Datastore.

google-cloud-sdk-pubsub-emulator/cloud-sdk-stretch 162.0.0-0 all
  Emulator for Google Cloud Pubsub.

google-cloud-sdk-tests/cloud-sdk-stretch 162.0.0-0 all
  Tests for verifying Google Cloud SDK packages.

myusername@instance-1:~$ 

Best Answer

I think you should look at dmesg output (or the journal) to figure out while the postinst script died:

Setting up google-cloud-sdk (162.0.0-0) ...
Killed
dpkg: error processing package google-cloud-sdk (--configure):
 subprocess installed post-installation script returned error exit status 137

This could be an out-of-memory error, for instance.