How to prevent prompt that ask to restart services when installing libpq-dev
Solution 1
Set the environment variable DEBIAN_FRONTEND=noninteractive
.
For example:
export DEBIAN_FRONTEND=noninteractive
apt-get install -y libpq-dev
This will make apt-get
select the default options.
Solution 2
You should be able to achieve this using debconf-set-selections
. From the man page:
debconf-set-selections can be used to pre-seed the debconf database
with answers, or to change answers in the database. Each question will
be marked as seen to prevent debconf from asking the question
interactively.
In order to determine the required input to debconf-set-selections
if unknown, you can answer the prompt manually and then inspect the debconf database to find the correct value. To do this, install debconf-utils
:
sudo apt-get -y install debconf-utils
which provides the debconf-get-selections
command. Then:
sudo debconf-get-selections | grep libssl1.0.0:amd64
to check the values in the database. On my system (Ubuntu, but Debian should be similar) I am not prompted when I apt-get install libpq-dev, and I have this entry:
libssl1.0.0:amd64 libssl1.0.0/restart-services string
so you should be able to use:
echo 'libssl1.0.0:amd64 libssl1.0.0/restart-services string' | sudo debconf-set-selections
to set the list of services to restart when upgrading libssl to 'none'.
Under Debian, there should be more information about valid values for this line in the questions.dat
file under /var/lib/cdebconf
. See https://www.debian.org/releases/stable/i386/apbs03.html.en for more details.
Solution 3
I think the existing answers may be a bit old. The following worked for me recently.
To see the settings for a package
sudo debconf-show <package-name>
E.G:
$ sudo debconf-show libssl1.1
libssl1.1/restart-services:
libssl1.1/restart-failed:
* libraries/restart-without-asking: false
To change the setting
echo '<package-and-setting-string>' | sudo debconf-set-selections
E.G
echo 'libssl1.1 libraries/restart-without-asking boolean true' | sudo debconf-set-selections
Bonus tip, to set this setting for all packages use '*' in place of the package name.
E.G
echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
Solution 4
You can disable this feature on Debian 11 by uninstalling the needrestart
package.
apt remove needrestart
Related videos on Youtube
OrangeTux
Updated on September 18, 2022Comments
-
OrangeTux over 1 year
I want to install
libpq-dev
on my Vagrant machine. I install it with$ apt-get install -y libpq-dev
During installation a prompt appears which asks if it's allowed to restart some services automatically. This prompt breaks my Vagrant provision. How can disable this prompt?
Text:
There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade.
****EDIT ****
Thanks to Patrick's answer and this question I fixed it. Now my Vagrantfile contains:
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libpq-dev
-
Marek Zakrzewski almost 10 yearsI was suggesting to use
-y
but seems it doesn't change much. seeman apt-get | less +/--force-yes
-
OrangeTux almost 10 yearsI've tried that optiont too, but that didn't worked either.
-
Niklas Mertsch over 3 yearsMaybe a bit late, but
-y
is an option forapt-get
, but the prompt in question comes fromdpkg
, the package management backend used by apt.DEBIAN_FRONTEND
is read bydpkg
, that's why it works in this case and-y
does not.
-
-
Nigel Horne almost 5 yearsDoesn't work in this case.
-
phemmer almost 5 yearsPlease specify what "this case" is. The author of the question has selected this answer as correct. If the answer does not work for you, I recommend you ask a new question and make sure to clarify how your case is different, and that this does not work for you.
-
Felipe almost 5 yearsIt didn't work for me neither.
-
Nicholi over 4 yearsIs the default option to restart the service or not restart the service?
-
RSHAP over 4 yearsdidn't work for me either -
export DEBIAN_FRONTEND=noninteractive; sudo apt-get update; sudo apt-get install -y libssl-dev openssl
. ubuntu 18 -
bradj over 4 yearsThe accepted answer did not work for me but using
debconf-set-selections
did. -
spikyjt about 4 years@RSHAP that's because you have exported the
DEBIAN_FRONTEND
variable in your shell, but the executed the commands withsudo
. This answer describes running the commands asroot
. When usingsudo
you will need to prefix each command with the environment variable, instead of exporting it, e.g.sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libssl-dev openssl