apt upgrade: Falha ao executar a operação: Nenhum arquivo ou diretório

1

Após a atualização de 14.04 para 16.04, o apt-get foi de alguma forma confuso no meu sistema xenial e não sei como consertá-lo. Isso que eu recebo (após apt update ).
Alguém pode oferecer alguns conselhos sobre como consertar isso?

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libsimgearcore3.4.0v5 libsimgearscene3.4.0v5 linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-97-generic linux-image-extra-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up snapd (2.28.5~14.04) ...
Failed to execute operation: No such file or directory
dpkg: error processing package snapd (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)

Eu também tentei executar apt -f install e recebi o seguinte:

$ sudo apt -f install
[sudo] password for ron: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libsimgearcore3.4.0v5 libsimgearscene3.4.0v5 linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-97-generic linux-image-extra-4.4.0-97-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up snapd (2.28.5~14.04) ...
Failed to execute operation: No such file or directory
dpkg: error processing package snapd (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 snapd
E: Sub-process /usr/bin/dpkg returned an error code (1)

onde $ sudo dpkdg --configure -a me dá:

$ sudo dpkg --configure -a
Setting up snapd (2.28.5~14.04) ...
Failed to execute operation: No such file or directory
dpkg: error processing package snapd (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 snapd

Onde sudo apt-get --remove purge snapd retorna:

$ sudo apt-get --remove purge snapd
[sudo] password for ron: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  cgroup-lite libsimgearcore3.4.0v5 libsimgearscene3.4.0v5 linux-generic-lts-xenial linux-headers-4.4.0-97 linux-headers-4.4.0-97-generic linux-image-4.4.0-97-generic
  linux-image-extra-4.4.0-97-generic squashfs-tools
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  snapd*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 74.5 MB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 661915 files and directories currently installed.)
Removing snapd (2.28.5~14.04) ...
Failed to stop snapd.autoimport.service: Unit snapd.autoimport.service not loaded.
Failed to stop snapd.socket: Unit snapd.socket not loaded.
Failed to stop snapd.service: Unit snapd.service not loaded.
dpkg: error processing package snapd (--purge):
 subprocess installed pre-removal script returned error exit status 5
Errors were encountered while processing:
 snapd
sudo aE: Sub-process /usr/bin/dpkg returned an error code (1)
    
por cerr 24.11.2017 / 02:39

2 respostas

2

A resposta de @vskubriev pode ser a chave para forçar a remoção.

Essencialmente:
Adicione exit 0 após o shebang para /var/lib/dpkg/info/snapd.prerm . Em seguida, execute os seguintes comandos.

dpkg --purge --force-all snapd
apt-get update

Opcionalmente, reinstale usando apt-get install snapd

Se a resposta do @ vskubriev ajudar a evitá-lo, não aqui.

    
por J. Starnes 28.11.2017 / 00:57
0

Como parece que você atualizou de 14.04 com snapd instalado para 16.04, e por algum motivo o pacote snapd não foi substituído, deixando-o com este problema, você pode executar o seguinte para remover o pacote:

#: sudo rm /var/lib/dpkg/info/snapd.p*rm
#: sudo apt-get remove --purge snapd

Isso excluirá os scripts de pré / pós-remoção e permitirá que o pacote seja removido à medida que o script estiver falhando. Se você precisa de snapd (porque você instalou alguns snaps anteriormente ou algo do tipo), você pode simplesmente executar:

#: sudo apt update
#: sudo apt install snapd
    
por dobey 26.11.2017 / 15:56