![尝试修复 Ubuntu Server 14.04 上的“未满足的依赖关系”时出错](https://linux22.com/image/1051226/%E5%B0%9D%E8%AF%95%E4%BF%AE%E5%A4%8D%20Ubuntu%20Server%2014.04%20%E4%B8%8A%E7%9A%84%E2%80%9C%E6%9C%AA%E6%BB%A1%E8%B6%B3%E7%9A%84%E4%BE%9D%E8%B5%96%E5%85%B3%E7%B3%BB%E2%80%9D%E6%97%B6%E5%87%BA%E9%94%99.png)
我正在尝试安装 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 main
是9.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
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