apt-get -f install 出现错误

apt-get -f install 出现错误

当我运行 apt-get -f install 时,出现以下错误:

# apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libcdio10 lp-solve libunique-1.0-0 libgmime-2.4-2 libcdio-paranoia0 hplip-cups libmagickcore3 libtaglib2.0-cil libgkeyfile1.0-cil
  zeitgeist-extension-fts libgudev1.0-cil linux-headers-3.0.0-12 libtextcat-data libgdata1.9-cil libglew1.5 libproxy0 libgexiv2-0
  libmagickwand3 libgnomevfs2-common linux-headers-3.0.0-12-server libgupnp-1.0-3 libwebkitgtk-1.0-common python-indicate libnux-1.0-common
  libboost-date-time1.46.1 libindicator3-6 linux-headers-3.0.0-19-generic banshee python-webkit python-aptdaemon.gtkwidgets libindicator6
  gir1.2-gconf-2.0 libjavascriptcoregtk-1.0-0 libept1 banshee-extension-soundmenu libgnomevfs2-0 libmono-zeroconf1.0-cil libvpx0
  python-telepathy libgdata1.7-cil libminiupnpc5 libnotify0.4-cil libpoppler-glib6 python-aptdaemon-gtk libtextcat0 libgtk-sharp-beans-cil
  gnome-utils-common libxss1 libhunspell-1.2-0 unity-2d-places libjpeg62:i386 libquvi0 libexiv2-10 libgupnp-igd-1.0-3 gnome-desktop-data
  libgtkspell3-0 libnautilus-extension1 libwebkitgtk-1.0-0 gir1.2-dee-0.5 libcdio-cdda0 libmusicbrainz4c2a python-wnck libmagickcore3-extra
  libglewmx1.5 libnux-1.0-0 libgmime2.4-cil libnatpmp1 unity-2d-launcher libgssdp-1.0-2 libllvm2.9
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  postgresql-9.1
Suggested packages:
  oidentd ident-server locales-all
The following packages will be upgraded:
  postgresql-9.1
1 upgraded, 0 newly installed, 0 to remove and 80 not upgraded.
2 not fully installed or removed.
Need to get 0 B/4,290 kB of archives.
After this operation, 295 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 252269 files and directories currently installed.)
Preparing to replace postgresql-9.1 9.1.3-0ubuntu0.11.10 (using .../postgresql-9.1_9.1.4-0ubuntu12.04_amd64.deb) ...
 * Stopping PostgreSQL 9.1 database server
 * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
                                                         [fail]
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.1 database server
 * Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 246.
Insecure directory in $ENV{PATH} while running with -T switch at /usr/bin/pg_ctlcluster line 255.
(does not shutdown gracefully, now stopping immediately)
                                                          [fail]
invoke-rc.d: initscript postgresql, action "stop" failed.
dpkg: error processing /var/cache/apt/archives/postgresql-9.1_9.1.4-0ubuntu12.04_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 /var/cache/apt/archives/postgresql-9.1_9.1.4-0ubuntu12.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试卸载 postgresql,但无法卸载。请提供建议。

答案1

我认为您是 Ubuntu 新手。sudo apt-get update <argument>只会更新存储库,它会显示错误,因为您有错误(坏)链接。更新存储库后,您必须运行sudo apt-get upgrade以下载并安装更新。因此,要完全更新您的 Ubuntu 电脑,您必须输入:

sudo apt-get update
sudo apt-get upgrade

第一个命令的更好命令是:

sudo apt-get update -fmy
  • 该论点f是为了修复未解决的(损坏的)依赖关系。
  • 即使档案无法定位,m也要尝试搜索。
  • 这个论点y是对每个查询都假设为是。

答案2

这是我修复它的方法:

sudo rm /var/lib/postgresql/$$$YOUR VERSION$$$/main/postmaster.pid
sudo chown postgres:postgres /etc/postgresql/$$$YOUR VERSION$$$/main/environment
sudo chmod u+rw,g+rw /etc/postgresql/$$$YOUR VERSION$$$/main/environment
sudo pkill postgresql
sudo service stop postgresql 
sudo apt-get -f install

确保用你的 posgresql 版本替换。我的是 9.3(只需将光标放在那里并点击Tab)。

相关内容