Resolve circular dependency loop between nginx and nginx-common
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nginx (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Noble |
Fix Committed
|
Medium
|
Matthew Ruffell | ||
Oracular |
Fix Committed
|
Medium
|
Matthew Ruffell |
Bug Description
[Impact]
If you use policy-rc.d to prevent unattended-upgrades from restarting your
services outside of a reboot or shutdown, it reveals a circular dependency
loop between nginx and nginx-common, where it cannot start nginx before
nginx-common is configured.
systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
nginx[1634]: 2025/02/07 02:21:56 [emerg] 1634#1634: open() "/etc/nginx/
nginx[1634]: nginx: configuration file /etc/nginx/
...
dpkg: error processing package nginx (--configure):
installed nginx package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of nginx-common:
nginx-common depends on nginx (<< 1.26.0-
Package nginx is not configured yet.
dpkg: error processing package nginx-common (--configure):
dependency problems - leaving unconfigured
The solution is to remove the circular dependency, by dropping the dependency for
nginx from nginx-common, as suggested by Thomas Ward.
[Testcase]
Deploy a fresh Noble or Oracular VM.
1) sudo vim /usr/sbin/
#!/bin/sh
exit 0
2) sudo chmod 755 /usr/sbin/
3) sudo apt update
4) sudo apt install -y nginx
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_
Unpacking nginx (1.26.0-2ubuntu3) ...
Setting up nginx (1.26.0-2ubuntu3) ...
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
invoke-rc.d: initscript nginx, action "start" failed.
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/
Active: failed (Result: exit-code) since Fri 2025-02-07 02:21:56 UTC; 8ms ago
Invocation: 774e214ca6b04b2
Docs: man:nginx(8)
Process: 1634 ExecStartPre=
Mem peak: 1.4M
CPU: 3ms
systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
nginx[1634]: 2025/02/07 02:21:56 [emerg] 1634#1634: open() "/etc/nginx/
nginx[1634]: nginx: configuration file /etc/nginx/
systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
systemd[1]: nginx.service: Failed with result 'exit-code'.
systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
dpkg: error processing package nginx (--configure):
installed nginx package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of nginx-common:
nginx-common depends on nginx (<< 1.26.0-
Package nginx is not configured yet.
dpkg: error processing package nginx-common (--configure):
dependency problems - leaving unconfigured
Processing triggers for ufw (0.36.2-6) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
nginx
nginx-common
needrestart is being skipped since dpkg has failed
Error: Sub-process /usr/bin/dpkg returned an error code (1)
Test packages are available in the following ppa:
https:/
If you install the test package, you can install nginx correctly with policy-rc.d.
We also need to test the upgrade path from old packages to new packages to
ensure there are no dependency issues.
[Where problems can occur]
We are changing the dependencies on the nginx-common package to not point back
to nginx. nginx already depends on nginx-common, so we shouldn't be dropping
any dependencies in the process.
If a regression were to occur, it would happen during apt dependency resolution
or package installation time, which for a lot of users will be handled by
unattended-
[Other info]
This was fixed in debian in 1.26.0-3 by Thomas Ward
https:/
affects: | ubuntu → nginx (Ubuntu) |
tags: | added: noble |
Changed in nginx (Ubuntu): | |
status: | New → Incomplete |
Changed in nginx (Ubuntu Noble): | |
status: | New → In Progress |
Changed in nginx (Ubuntu Oracular): | |
status: | New → In Progress |
Changed in nginx (Ubuntu Noble): | |
importance: | Undecided → Medium |
Changed in nginx (Ubuntu Oracular): | |
importance: | Undecided → Medium |
Changed in nginx (Ubuntu Noble): | |
assignee: | nobody → Matthew Ruffell (mruffell) |
Changed in nginx (Ubuntu Oracular): | |
assignee: | nobody → Matthew Ruffell (mruffell) |
Changed in nginx (Ubuntu): | |
status: | Incomplete → Fix Released |
description: | updated |
tags: | added: oracular sts |
@Adam, may I ask why you are using exit code 0?
I'm more used to exit code 101 when you want to prevent service restarts for example. Also, I just test with 101 and it doesn't prevent the installation.
https:/ /manpages. ubuntu. com/manpages/ noble/man8/ invoke- rc.d.8. html#status% 20codes