意外删除安装文件夹后删除程序

意外删除安装文件夹后删除程序

意外删除了该程序的安装文件夹后,如何删除或重新安装程序?

我意外删除了/opt/spotify/文件夹并且无法重新安装spotify-client或清除它。

 sudo apt-get purge spotify-client
 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 The following packages will be REMOVED:
   spotify-client*
 0 upgraded, 0 newly installed, 1 to remove and 45 not upgraded.
 1 not fully installed or removed.
 After this operation, 143 MB disk space will be freed.
 Do you want to continue? [Y/n] 
 (Reading database ... 276312 files and directories currently installed.)
 Removing spotify-client (1:0.9.17.1.g9b85d43.7-1) ...
 /var/lib/dpkg/info/spotify-client.prerm: 9: cd: can't cd to /opt/spotify/spotify-client
 dpkg: error processing package spotify-client (--purge):
  subprocess installed pre-removal script returned error exit status 2
 /var/lib/dpkg/info/spotify-client.postinst: 5: cd: can't cd to /opt/spotify/spotify-client
 dpkg: error while cleaning up:
  subprocess installed post-installation script returned error exit status 2
 Errors were encountered while processing:
  spotify-client
 E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt-get install --reinstall spotify-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 45 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for spotify-client:amd64

当然,文件夹不在垃圾桶里!谢谢!

答案1

apt你可以使用和的组合来解决这种情况dpkg。首先从存储库下载 deb 包

apt-get download <packagename>

然后安装.deb 文件(位于当前文件夹中)

sudo dpkg -i <downloaded_package_file.deb>

如果这不起作用,请将--force-all开关添加到dpkg,即

sudo dpkg -i --force-all <downloaded_package_file.deb>

如果仍然不起作用,还添加--no-triggers

sudo dpkg -i --force-all --no-triggers <downloaded_package_file.deb>

作为最后的手段(不建议),您可以手动编辑/var/lib/dpkg/status

  • 备份文件
  • 查找并删除有关spotify-client
  • 在下一个块之前保留空行
  • 节省
  • apt-get -f install spotify-client

答案2

我通常做的是获取软件包的文件列表,然后清除所有这些文件,然后重新安装:

  1. 消除:apt-get remove spotify-client
  2. 彻底清除文件:apt-file list spotify-client | cut -d' ' -f 2 | xargs rm -rf
  3. 然后重新安装:apt-get install spotify-client

相关内容