记一次偷懒导致的教训

前情提要

在搭建博客的时候,想着在 VPS 上测试一下效果,于是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ sudo apt install nodejs npm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libssl-dev : Depends: libssl3 (= 3.0.13-1~deb12u1)
libuv1t64 : Breaks: libuv1 (< 1.48.0-1.1)
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

很奇怪,为什么会装不上?所以理所应当的敲下了

1
2
$ sudo apt install aptitude 
$ aptitude nodejs npm

这下子很顺利,终端输出了一长串的待安装的包,但是出现了两个无法解决的依赖问题,aptitude给出了解决方案,很自然的输入 Y 一路往下走(注意这里的neovim,这里是伏笔)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
$ aptitude install nodejs npm
The following NEW packages will be installed:
cpp{a} cpp-12{a} eslint{a} gyp{a} handlebars{a} javascript-common{a} libauthen-sasl-perl{a} libc-ares2{a} libclone-perl{a}
libdata-dump-perl{a} libdrm-amdgpu1{a} libdrm-common{a} libdrm-intel1{a} libdrm-nouveau2{a} libdrm-radeon1{a} libdrm2{a}
.....
.....
perl-openssl-defaults{a} terser{a} webpack{a} x11-utils{a} x11-xserver-utils{a} xdg-utils{a} zutty{a}
0 packages upgraded, 493 newly installed, 0 to remove and 0 not upgraded.
Need to get 84.1 MB of archives. After unpacking 401 MB will be used.
The following packages have unmet dependencies:
libuv1-dev : Depends: libuv1 (= 1.44.2-1+deb12u1) but it is not going to be installed
libssl-dev : Depends: libssl3 (= 3.0.13-1~deb12u1) but it is not going to be installed
The following actions will resolve these dependencies:

Remove the following packages:
1) libuv1t64 [1.48.0-5 (now)]
2) lua-luv [1.48.0-2-2 (now)]
3) neovim [0.9.5-7+b1 (now)]

Install the following packages:
4) libuv1 [1.44.2-1+deb12u1 (stable, stable-security)]

Keep the following packages at their current version:
5) libnode-dev [Not Installed]
6) libssl-dev [Not Installed]
7) node-gyp [Not Installed]
8) npm [Not Installed]

Leave the following dependencies unresolved:
9) python3-pynvim recommends neovim



Accept this solution? [Y/n/q/?] Y
The following NEW packages will be installed:
cpp{a} cpp-12{a} libauthen-sasl-perl{a} libc-ares2{a} libclone-perl{a} libdata-dump-perl{a} libdrm-amdgpu1{a} libdrm-common{a}
libdrm-intel1{a} libdrm-nouveau2{a} libdrm-radeon1{a} libdrm2{a} libegl-mesa0{a} libegl1{a} libencode-locale-perl{a}
.....
.....
x11-utils{a} x11-xserver-utils{a} xdg-utils{a} zutty{a}
The following packages will be REMOVED:
libmsgpack-c2{u} libtermkey1{u} libtree-sitter0{u} libunibilium4{u} libuv1t64{a} libvterm0{u} lua-luv{a} neovim{a} neovim-runtime{u}
python3-greenlet{u} python3-msgpack{u} python3-pynvim{u} xclip{u}
0 packages upgraded, 107 newly installed, 13 to remove and 0 not upgraded.
Need to get 69.7 MB of archives. After unpacking 260 MB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://deb.debian.org/debian bookworm/main amd64 libuv1 amd64 1.44.2-1+deb12u1 [136 kB]
Get: 2 http://deb.debian.org/debian bookworm/main amd64 libisl23 amd64 0.25-1.1 [683 kB]
......
......
Get: 106 http://deb.debian.org/debian bookworm/main amd64 libegl1 amd64 1.6.0-1 [33.7 kB]
Get: 107 http://deb.debian.org/debian bookworm/main amd64 zutty amd64 0.14.0.20230218+dfsg1-1 [177 kB]
Fetched 69.7 MB in 12s (5,764 kB/s)
Extracting templates from packages: 100%
(Reading database ... 46085 files and directories currently installed.)
Removing neovim (0.9.5-7+b1) ...
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/ex (ex) in auto mode
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.tiny to provide /usr/bin/view (view) in auto mode
Removing libmsgpack-c2:amd64 (6.0.1-3) ...
Removing libtermkey1:amd64 (0.22-1) ...
Removing libtree-sitter0:amd64 (0.20.8-2+b1) ...
Removing libunibilium4:amd64 (2.1.0-1) ...
Removing lua-luv:amd64 (1.48.0-2-2) ...
dpkg: libuv1t64:amd64: dependency problems, but removing anyway as you requested:
bind9-libs:amd64 depends on libuv1 (>= 1.40.0); however:
Package libuv1 is not installed.
Package libuv1t64:amd64 which provides libuv1 is to be removed.

Removing libuv1t64:amd64 (1.48.0-5) ...
Selecting previously unselected package libuv1:amd64.
(Reading database ... 46018 files and directories currently installed.)
Preparing to unpack .../libuv1_1.44.2-1+deb12u1_amd64.deb ...
Unpacking libuv1:amd64 (1.44.2-1+deb12u1) ...
(Reading database ... 46022 files and directories currently installed.)
Removing libvterm0:amd64 (0.3.3-3) ...
Removing neovim-runtime (0.9.5-7) ...
Removing python3-pynvim (0.4.2-2) ...
Removing python3-greenlet (2.0.2-1) ...
Removing python3-msgpack (1.0.3-2+b1) ...
Removing xclip (0.13-2) ...
Selecting previously unselected package libisl23:amd64.
(Reading database ... 44066 files and directories currently installed.)
.....
.....
Selecting previously unselected package zutty.
Preparing to unpack .../105-zutty_0.14.0.20230218+dfsg1-1_amd64.deb ...
Unpacking zutty (0.14.0.20230218+dfsg1-1) ...
Setting up libxcb-dri3-0:amd64 (1.15-1) ...
Setting up libwayland-server0:amd64 (1.21.0-1) ...
.....
.....
Setting up libglx0:amd64 (1.6.0-1) ...
Setting up libgl1:amd64 (1.6.0-1) ...
Setting up zutty (0.14.0.20230218+dfsg1-1) ...
update-alternatives: using /usr/bin/zutty to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in auto mode
Setting up x11-utils (7.7+5) ...
Setting up node-acorn (8.8.1+ds+~cs25.17.7-2) ...
Setting up liblwp-protocol-https-perl (6.10-1) ...
Setting up libwww-perl (6.68-1) ...
Setting up libnode108:amd64 (18.19.0+dfsg-6~deb12u2) ...
Setting up nodejs (18.19.0+dfsg-6~deb12u2) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Setting up libxml-parser-perl (2.46-4) ...
Setting up libxml-twig-perl (1:3.52-2) ...
Setting up libnet-dbus-perl (1.2.0-2) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for mailcap (3.70+nmu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for libc-bin (2.39-6) ...

刚刚说到这里有一个伏笔,在安装 NodeJS 的时候可以看到 NeoVim 被删除了

为什么这里会遇到需要卸载 NeoVim 这一步呢? 这就要说到文章的标题了

是的,我偷了一个懒。

故事的开始

那是一个月光明媚的晚上, 在心情激动的买下了一台主机后,Debian12一装,开始了经典的 VPSBench 环节。于是,万事不决,先装 Neovim。

1
$ sudo apt install neovim

然而,加载 Neovim 配置的时候, 出现了一些问题。Debian 12 源中,默认的 Neovim 版本是 0.7.2-7 ,如果想要使用 LazyVim 来管理配置插件,这个版本是不够的。想到刚买的主机只是一台 E5v3 的 1C1G 小鸡,从源码编译属实有些累着它老人家了。脑子里突然冒出了天才的想法:何不切换到测试版安装后在切回来呢? 说干就干,直接打开 MirrorZ ,testing? sid !

很顺利的,Neovim 顺利安装了,APT 源切换回来后也暂时 有发现什么问题,配置成功加载出来后就安心睡觉了。

伤心总在编译时

奇怪的依赖

前文提到 Neovim 被 Aptitude 卸载了,在等待安装 NodeJS 的过程中便开始着手解决这一问题,毕竟不可能真的退回去使用 Vim 。 既然在包管理安装的时候会出现依赖问题,那么从源码安装便成了无奈的选择。从 GitHub 仓库中克隆代码到本地,根据 BUILD.md 的指引安装相关依赖。叮,在这一步卡住了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ sudo apt-get install ninja-build gettext cmake unzip curl build-essential
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
cmake is already the newest version (3.25.1-1).
unzip is already the newest version (6.0-28).
curl is already the newest version (7.88.1-10+deb12u6).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.36-9+deb12u7) but 2.39-6 is to be installed
Depends: libc-dev-bin (= 2.36-9+deb12u7) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

卡住了那就切 aptitude , 但是运行完过后也还是原来的样子, 多运行几遍给出了一个如下的解决方案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$ aptitude install ninja-build gettext cmake unzip curl build-essential
ninja-build is already installed at the requested version (1.11.1-1)
gettext is already installed at the requested version (0.21-12)
cmake is already installed at the requested version (3.25.1-1)
unzip is already installed at the requested version (6.0-28)
curl is already installed at the requested version (7.88.1-10+deb12u6)
ninja-build is already installed at the requested version (1.11.1-1)
gettext is already installed at the requested version (0.21-12)
cmake is already installed at the requested version (3.25.1-1)
unzip is already installed at the requested version (6.0-28)
curl is already installed at the requested version (7.88.1-10+deb12u6)
The following NEW packages will be installed:
build-essential{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,704 B of archives. After unpacking 20.5 kB will be used.
The following packages have unmet dependencies:
build-essential : Depends: libc6-dev but it is not installable or
libc-dev which is a virtual package, provided by:
- libc6-dev (2.36-9+deb12u7), but it is not installable

Depends: g++ (>= 4:10.2) but it is not installable
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) build-essential [Not Installed]

终端输出中可以看到

Depends: g++ (>= 4:10.2) but it is not installable

g++ 无法安装? 用 apt 单独安装尝试一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ apt install gcc g++
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gcc is already the newest version (4:12.2.0-3).
gcc set to manually installed.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libc6-dev : Depends: libc6 (= 2.36-9+deb12u7) but 2.39-6 is to be installed
Depends: libc-dev-bin (= 2.36-9+deb12u7) but it is not going to be installed

又回到了一开始的地方。这时候翻了翻浏览器,尝试重新切换镜像源,apt update && apt upgrade 反复执行,最后也没有什么效果,那还是回到最初的报错信息中来。

尝试修复

既然问题出在 libc6libc-dev-bin这两个包上,那么很显然从这二位下手可能会起到些什么效果。

先看 libc6 , 来试一下删除这个包如何? ( 请不要轻易在你的服务器上尝试 | CAUTION : DO NOT DO THAT IN YOUR SERVERS! )

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$ apt remove libc6
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
apt : Depends: adduser but it is not going to be installed
Depends: gpgv but it is not going to be installed or
gpgv2 but it is not going to be installed or
gpgv1 but it is not going to be installed
Depends: libapt-pkg6.0 (>= 2.6.1) but it is not going to be installed
Depends: libc6 (>= 2.34) but it is not going to be installed
Depends: libgnutls30 (>= 3.7.5) but it is not going to be installed
Depends: libseccomp2 (>= 2.4.2) but it is not going to be installed
Depends: libstdc++6 (>= 11) but it is not going to be installed
Depends: libsystemd0
Recommends: ca-certificates but it is not going to be installed

.....
.....

util-linux : PreDepends: libblkid1 (>= 2.37.2) but it is not going to be installed
PreDepends: libc6 (>= 2.34) but it is not going to be installed
PreDepends: libcap-ng0 (>= 0.7.9) but it is not going to be installed
PreDepends: libmount1 (>= 2.38) but it is not going to be installed
PreDepends: libpam0g (>= 0.99.7.1) but it is not going to be installed
PreDepends: libselinux1 (>= 3.1~) but it is not going to be installed
PreDepends: libsmartcols1 (>= 2.38) but it is not going to be installed
PreDepends: libsystemd0
PreDepends: libtinfo6 (>= 6) but it is not going to be installed
PreDepends: libudev1 (>= 183) but it is not going to be installed
PreDepends: libuuid1 (>= 2.16) but it is not going to be installed
PreDepends: zlib1g (>= 1:1.1.4) but it is not going to be installed
Depends: util-linux-extra but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
$ apt install libc6
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libc6 is already the newest version (2.39-6).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

重启机器, 问题依旧。

漫漫降级路

这个时候,万般思绪中看到

libc6 (= 2.36-9+deb12u7) but 2.39-6 is to be installed

机器上 libc6 的版本比依赖编译的要求要高。那么很显然,之前切换到 sid 源还是造成了麻烦。既然找到了这里,那么接下来需要做的就是怎么降级 libc6 了。但一看这个包名就知道,这只是系统中上次换源遗留下问题的冰山一角,最直接明了的方式就是找出所有需要降级的包,将他降级成当前系统(bookworm)最新的版本。

经过一番搜索,在这里找到了一份 Python 代码,能够找到当前系统中版本不匹配的包,并生成 aptitude 命令重装,把代码记录在这里。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
# Downgrade apt packages

import os
import sys
import subprocess

def list_installed_pkgs():
output = subprocess.getoutput("dpkg -l | grep '^ii' | awk '{print $2}'")
return output.split("\n")

def filter_downgrade_pkg(pkg):
output = subprocess.getoutput("apt-cache policy %s" % pkg)
downgrade = False
for line in output.split("\n"):
if "/var/lib/dpkg/status" in line:
downgrade = True
elif downgrade:
parts = line.strip().split(" ")
return parts[0]
return ""

def main():
installed_pkgs = list_installed_pkgs()

print("sudo aptitude install", end=" ")
for pkg in installed_pkgs:
out = filter_downgrade_pkg(pkg)
if out:
print("%s=%s" % (pkg, out), end=" ")

if __name__ == "__main__":
main()

这段代码的工作原理是, 如果你系统中某个包的版本和源不匹配,通过 apt-cache指令,如果存在版本不匹配,那么会出现运行 100 /var/lib/dpkg/status,这表示你当前安装的包版本是从本地状态文件中读取的,而不是从软件包源中直接获取的,即当前的版本和源中的版本不匹配。

1
2
3
4
5
6
7
8
9
10
$ apt-cache policy zstd
zstd:
Installed: 1.5.6+dfsg-1
Candidate: 1.5.6+dfsg-1
Version table:
*** 1.5.6+dfsg-1 100
100 /var/lib/dpkg/status
1.5.4+dfsg2-5 500
500 http://deb.debian.org/debian bookworm/main amd64 Packages
500 https://mirrors.xtom.com.hk/debian bookworm/main amd64 Packages

运行代码,得到用于降级的 aptitude 指令,执行!

然而,事情没有这么简单。aptitude 还是显示存在问题,切换了很多个方案,最后用了一个看似可以的解决方案,输入 Y 执行。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
$ aptitude install base-files=12.4+deb12u6 bind9-dnsutils=1:9.18.24-1 bind9-host=1:9.18.24-1 bind9-libs:amd64=1:9.18.24-1 curl=7.88.1-10+deb12u5 dnsutils=1:9.18.24-1 intel-microcode=3.20231114.1~deb12u1 krb5-locales=1.20.1-2+deb12u1 libc-l10n=2.36-9+deb12u7 libcurl3-gnutls:amd64=7.88.1-10+deb12u5 libcurl4:amd64=7.88.1-10+deb12u5 libglib2.0-0:amd64=2.74.6-2+deb12u2 libglib2.0-data=2.74.6-2+deb12u2 libgssapi-krb5-2:amd64=1.20.1-2+deb12u1 libk5crypto3:amd64=1.20.1-2+deb12u1 libkrb5-3:amd64=1.20.1-2+deb12u1 libkrb5support0:amd64=1.20.1-2+deb12u1 libnode108:amd64=18.19.0+dfsg-6~deb12u1 libpq5:amd64=15.6-0+deb12u1 libssl3:amd64=3.0.11-1~deb12u2 libsystemd-shared:amd64=252.26-1~deb12u2 libsystemd0:amd64=252.26-1~deb12u2 libudev1:amd64=252.26-1~deb12u2 libzstd1:amd64=1.5.4+dfsg2-5 linux-base=4.9 linux-libc-dev:amd64=6.1.94-1 node-undici=5.15.0+dfsg1+~cs20.10.9.3-1+deb12u3 nodejs=18.19.0+dfsg-6~deb12u1 nodejs-doc=18.19.0+dfsg-6~deb12u1 openssh-client=1:9.2p1-2+deb12u2 openssh-server=1:9.2p1-2+deb12u2 openssh-sftp-server=1:9.2p1-2+deb12u2 openssl=3.0.11-1~deb12u2 python3-cryptography=38.0.4-3~deb12u1 systemd-sysv=254.16-1~bpo12+1 zstd=1.5.4+dfsg2-5
The following packages will be DOWNGRADED:
base-files bind9-dnsutils bind9-host bind9-libs curl dnsutils intel-microcode krb5-locales libc-l10n libcurl3-gnutls libcurl4 libglib2.0-0 libglib2.0-data libgssapi-krb5-2 libk5crypto3 libkrb5-3
libkrb5support0 libnode108 libpq5 libssl3 libsystemd-shared libsystemd0 libudev1 libzstd1 linux-base linux-libc-dev node-undici nodejs nodejs-doc openssh-client openssh-server openssh-sftp-server openssl
python3-cryptography systemd-sysv zstd
The following partially installed packages will be configured:
systemd{b} udev{b}
The following packages are RECOMMENDED but will NOT be installed:
libnss-systemd libpam-elogind libpam-systemd
0 packages upgraded, 0 newly installed, 36 downgraded, 0 to remove and 0 not upgraded.
Need to get 37.9 MB/39.3 MB of archives. After unpacking 2,714 kB will be freed.
The following packages have unmet dependencies:
udev : Depends: libudev1 (= 254.16-1~bpo12+1) but 252.26-1~deb12u2 is to be installed
systemd : Depends: libsystemd-shared (= 254.16-1~bpo12+1) but 252.26-1~deb12u2 is to be installed
Depends: libsystemd0 (= 254.16-1~bpo12+1) but 252.26-1~deb12u2 is to be installed
The following actions will resolve these dependencies:

Remove the following packages:
1) cloud-initramfs-growroot [0.18.debian13 (now, stable)]
2) initramfs-tools [0.142 (now, stable)]
3) initramfs-tools-core [0.142 (now, stable)]
4) systemd [254.16-1~bpo12+1 (now, stable-backports)]
5) systemd-sysv [256.4-2 (now)]
6) udev [254.16-1~bpo12+1 (now, stable-backports)]

Install the following packages:
7) initscripts [3.06-4 (stable)]
8) insserv [1.24.0-1 (stable)]
9) orphan-sysvinit-scripts [0.14 (stable)]
10) psmisc [23.6-1 (stable)]
11) startpar [0.65-1+b1 (stable)]
12) sysv-rc [3.06-4 (stable)]
13) sysvinit-core [3.06-4 (stable)]
14) tiny-initramfs [0.1-5 (stable)]
15) tiny-initramfs-core [0.1-5+b13 (stable)]

Leave the following dependencies unresolved:
16) intel-microcode recommends initramfs-tools (>= 0.113~)

.....
.....

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

Remove the following packages:
1) systemd [254.16-1~bpo12+1 (now, stable-backports)]
2) systemd-sysv [256.4-2 (now)]

Install the following packages:
3) initscripts [3.06-4 (stable)]
4) insserv [1.24.0-1 (stable)]
5) opensysusers [0.7.3-2 (stable)]
6) orphan-sysvinit-scripts [0.14 (stable)]
7) psmisc [23.6-1 (stable)]
8) startpar [0.65-1+b1 (stable)]
9) sysv-rc [3.06-4 (stable)]
10) sysvinit-core [3.06-4 (stable)]

Keep the following packages at their current version:
11) libudev1 [254.16-1~bpo12+1 (now, stable-backports)]



Accept this solution? [Y/n/q/?] Y
The following packages will be DOWNGRADED:
base-files bind9-dnsutils bind9-host bind9-libs curl dnsutils intel-microcode krb5-locales libc-l10n libcurl3-gnutls libcurl4 libglib2.0-0 libglib2.0-data libgssapi-krb5-2 libk5crypto3 libkrb5-3
libkrb5support0 libnode108 libpq5 libssl3 libsystemd-shared libsystemd0 libzstd1 linux-base linux-libc-dev node-undici nodejs nodejs-doc openssh-client openssh-server openssh-sftp-server openssl
python3-cryptography zstd
The following NEW packages will be installed:
initscripts{a} insserv{a} opensysusers{a} orphan-sysvinit-scripts{a} psmisc{a} startpar{a} sysv-rc{a} sysvinit-core{a}
The following packages will be REMOVED:
systemd{a} systemd-sysv{a}
The following partially installed packages will be configured:
udev
The following packages are RECOMMENDED but will NOT be installed:
libpam-elogind libpam-systemd
0 packages upgraded, 8 newly installed, 34 downgraded, 2 to remove and 1 not upgraded.
Need to get 37.7 MB/39.8 MB of archives. After unpacking 11.5 MB will be freed.
Do you want to continue? [Y/n/?] Y
Get: 1 http://deb.debian.org/debian bookworm/main amd64 base-files amd64 12.4+deb12u6 [70.8 kB]
Get: 2 http://security.debian.org/debian-security bookworm-security/main amd64 libssl3 amd64 3.0.11-1~deb12u2 [2,019 kB]
Get: 3 http://deb.debian.org/debian bookworm/main amd64 opensysusers all 0.7.3-2 [14.3 kB]
.....
.....
Get: 34 http://security.debian.org/debian-security bookworm-security/main amd64 python3-cryptography amd64 38.0.4-3~deb12u1 [666 kB]
Fetched 37.7 MB in 7s (5,574 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
dpkg: warning: downgrading base-files from 13.3 to 12.4+deb12u6
(Reading database ... 56853 files and directories currently installed.)
Preparing to unpack .../base-files_12.4+deb12u6_amd64.deb ...
Unpacking base-files (12.4+deb12u6) over (13.3) ...
dpkg: warning: unable to delete old directory '/usr/lib64': Directory not empty
Setting up base-files (12.4+deb12u6) ...
Installing new version of config file /etc/debian_version ...
Installing new version of config file /etc/issue ...
Installing new version of config file /etc/issue.net ...
dpkg: systemd-sysv: dependency problems, but removing anyway as you requested:
init depends on systemd-sysv | sysvinit-core; however:
Package systemd-sysv is to be removed.
Package sysvinit-core is not installed.

(Reading database ... 56846 files and directories currently installed.)
Removing systemd-sysv (256.4-2) ...
Selecting previously unselected package sysvinit-core.
(Reading database ... 56830 files and directories currently installed.)
Preparing to unpack .../0-sysvinit-core_3.06-4_amd64.deb ...
Adding 'diversion of /usr/share/man/de/man8/init.8.gz to /usr/share/man/de/man8/init.8.dist by sysvinit-core'
.....
.....
/sbin/modprobe: error while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory
depmod: error while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory
Errors were encountered while processing:
systemd

Errors were encountered while processing:
systemd

到了这一步很茫然,尝试重装 systemd,尝试 aptitude 切换解决方案都没有解决, 好像只剩下重装系统这一条路。

柳暗花明

最后的解决契机出现在这一行上

/sbin/modprobe: error while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory

在 Google 上搜索,stack overflowkoijigen 的一个回答指出

At the issue in my Github repository , I knew that libcrypto is a library that is included the package openssl .

尝试重装 openssl ,还是失败。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ apt-get reinstall openssl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,418 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 56653 files and directories currently installed.)
Preparing to unpack .../openssl_3.0.13-1~deb12u1_amd64.deb ...
Unpacking openssl (3.0.13-1~deb12u1) over (3.0.13-1~deb12u1) ...
Setting up systemd (254.16-1~bpo12+1) ...
systemd-machine-id-setup: error while loading shared libraries: libcrypto.so.3: cannot open shared object file: No such file or directory
dpkg: error processing package systemd (--configure):
installed systemd package post-installation script subprocess returned error exit status 127
Setting up openssl (3.0.13-1~deb12u1) ...
Processing triggers for man-db (2.11.2-2) ...
Errors were encountered while processing:
systemd
E: Sub-process /usr/bin/dpkg returned an error code (1)

最终,在 askubuntu.com 上找到了解决方案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ sudo apt reinstall libssl3-dev
sudo apt reinstall libssl3

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/2,022 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 56657 files and directories currently installed.)
Preparing to unpack .../libssl3_3.0.13-1~deb12u1_amd64.deb ...
Unpacking libssl3:amd64 (3.0.13-1~deb12u1) over (3.0.13-1~deb12u1) ...
Setting up libssl3:amd64 (3.0.13-1~deb12u1) ...
Setting up systemd (254.16-1~bpo12+1) ...
groupadd: invalid group ID '4:65534'
groupadd: invalid group ID '42:65534'
groupadd: invalid group ID '65534:65534'
Processing triggers for libc-bin (2.36-9+deb12u7) ...

安装完成后,执行上文 Python 代码输出的指令

风平浪静

尾声

经过这一系列的折腾,总算是能够成功从包管理器上安装 nodejs 和 npm了,Neovim也变已安装上了最新版。

貌似这又是一个 OpenSSL 相关的问题,算是领教了一回。

累了;D, 消耗了一晚上的垃圾时间,博客的测试什么的就等下次吧。