尝试修复 Ubuntu Server 14.04 上的“未满足的依赖关系”时出错

尝试修复 Ubuntu Server 14.04 上的“未满足的依赖关系”时出错

我正在尝试安装 php5-dev:

sudo apt-get install php5-dev

但是我收到了这个错误:

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 postgresql-contrib-9.3 : Depends: postgresql-9.3 (= 9.3.9-0ubuntu0.14.04) but 9.3.5-0ubuntu0.14.04.1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

因此我运行以下命令:

sudo apt-get -f install

但后来我收到这个错误:

invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
 * Stopping PostgreSQL 9.3 database server
 * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 264.
(does not shutdown gracefully, now stopping immediately)

[fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing archive /var/cache/apt/archives/postgresql-9.3_9.3.9-0ubuntu0.14.04_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/postgresql-9.3_9.3.9-0ubuntu0.14.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我的配置:

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS
Release:        14.04
Codename:       trusty

我不知道如何解决这个问题...有人能帮助我吗?

答案1

它无法停止,因此请尝试手动停止它:

sudo service postgresql stop

确保 apt 缓存是最新的:

sudo apt-get update

再次尝试修复:

sudo apt-get -f install

如果不起作用,请彻底清除 postgresql。查看安装了哪些 postgresql 包:

dpkg -l | grep postgresql

然后,用 删除sudo apt-get remove <package name>。注意“以下软件包将被删除”之类的消息,如果其中列出了重要内容,请不要接受。

再试一次来修复:

sudo apt-get -f install

...

答案2

postgresql-9.3中的当前版本trusty main9.3.7-0ubuntu0.14.04。要安装,9.3.9-0ubuntu0.14.04您需要trusty-updates main

打开文件/etc/apt/sources.list

sudo nano /etc/apt/sources.list

并检查您是否已启用trusty-updates存储库至少main

例如:

deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe

结果Ubuntu 软件包搜索

Paket postgresql-9.3

    trusty (14.04LTS) (database): object-relational SQL database, version 9.3 server
    9.3.7-0ubuntu0.14.04 [security]: amd64 i386
    trusty-updates (database): object-relational SQL database, version 9.3 server
    9.3.9-0ubuntu0.14.04: amd64 i386

相关内容