升级 ubuntu-advantage-tools 时出错

升级 ubuntu-advantage-tools 时出错

坐下来工作做例行工作apt update && apt upgrade并遇到一些问题ubuntu-advantage-tools

我不确定这个包是做什么用的,但它是随 Ubuntu 20.04.2 LTS(GNU/Linux 5.4.72-microsoft-standard-WSL2 x86_64)一起提供的。

我尝试了常规方法apt purge并尝试再次安装,但仍然没有成功。

$ sudo apt install ubuntu-minimal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  ubuntu-advantage-tools
The following NEW packages will be installed:
  ubuntu-advantage-tools ubuntu-minimal
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/847 kB of archives.
After this operation, 3233 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package ubuntu-advantage-tools.
(Reading database ... 58786 files and directories currently installed.)
Preparing to unpack .../ubuntu-advantage-tools_27.2.1~20.04.1_amd64.deb ...
Unpacking ubuntu-advantage-tools (27.2.1~20.04.1) ...
Selecting previously unselected package ubuntu-minimal.
Preparing to unpack .../ubuntu-minimal_1.450.2_amd64.deb ...
Unpacking ubuntu-minimal (1.450.2) ...
Setting up ubuntu-advantage-tools (27.2.1~20.04.1) ...
ERROR: File not found '/run/cloud-init/instance-data.json'. Provide a path to instance data json file using --instance-data
dpkg: error processing package ubuntu-advantage-tools (--configure):
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          dpkg: dependency problems prevent configuration of ubuntu-minimal:
 ubuntu-minimal depends on ubuntu-advantage-tools; however:
  Package ubuntu-advantage-tools is not configured yet.

dpkg: error processing package ubuntu-minimal (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.9.1-1) ...
Errors were encountered while processing:
 ubuntu-advantage-tools
 ubuntu-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

我只是展示了安装的例子,ubuntu-minimal因为(我认为)这是唯一依赖于的东西ubuntu-advantage-tools,而删除ubuntu-advantage-tools也会删除ubuntu-minimal

我可以重新创建我的 Ubuntu WSL,但这有点麻烦。我没有得到 Canonical 的商业支持,我需要担心这个包有问题吗?ubuntu-minimal实际上,我更担心那个元包被破坏。

谢谢!

我最终“重置”了我的 WSL Ubuntu 安装,执行了初始“apt update && apt full-upgrade -y && apt autoremove -y”,错误再次出现。也许 Ubuntu 现在有一个有缺陷的软件包?

[... bunch of other apt output here ...]

Setting up ubuntu-advantage-tools (27.2.1~20.04.1) ...
Installing new version of config file /etc/ubuntu-advantage/uaclient.conf ...
ERROR: File not found '/run/cloud-init/instance-data.json'. Provide a path to instance data json file using --instance-data
dpkg: error processing package ubuntu-advantage-tools (--configure):
 installed ubuntu-advantage-tools package post-installation script subprocess returned error exit status 1

[... bunch of other apt output here ...]

Errors were encountered while processing:
 ubuntu-advantage-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

就我的情况(Ubuntu 18.04)而言,这导致了一个问题,因为该包需要一些未安装的 Python3 包,而 apt 无法完成安装。

对我来说,解决方法是删除 ubuntu-advantage-tools 来安装 python3 包,然后重新安装

要从 apt 中硬删除 ubuntu-advantage-tools 引用:

sudo mv /var/lib/dpkg/info/ubuntu-advantage-tools* /tmp

答案2

ubuntu-advantage-tools 升级配置失败 错误 #1938097

sudo vim +295 /var/lib/dpkg/info/ubuntu-advantage-tools.postinst
# or use gedit, nano, or else

改变295 行

cloud_id=$(cloud-id || true)

进行此更改然后

run dpkg --configure -a

另一种解决方法是卸载 cloud-init 包。如果没有安装此包,则无法找到 cloud-init,因此不会发生错误。

相关内容