如何安装 curl(依赖于 libcurl4)和 mongodb(依赖于 libcurl3)?

如何安装 curl(依赖于 libcurl4)和 mongodb(依赖于 libcurl3)?

在 Lubuntu 18.04 上,我已经安装了 mongodb,方法如下https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition

sudo apt install -y mongodb-org mongodb-org-server libcurl3

现在要安装 curl

$ sudo apt install curl
Reading package lists... Done
Building dependency tree       
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:
 curl : Depends: libcurl4 (= 7.58.0-2ubuntu3.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我跟着https://askubuntu.com/a/1051988/1471

您可以使用 apt 降级机制(因此,不需要卸载依赖于 libcurl4 的软件包)。

apt install -y libcurl4=7.58.0-2ubuntu3
apt install -y curl

但后来 libcurl3 和 mongodb 被删除了

$ sudo apt install -y libcurl4=7.58.0-2ubuntu3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  calibre-bin fonts-mathjax geoclue-2.0 iio-sensor-proxy libbrotli1 libchm1 libgeoclue-2-0 libjs-coffeescript libjs-mathjax libpodofo0.9.5 libqt5designer5 libqt5help5
  libqt5positioning5 libqt5sensors5 libqt5sql5 libqt5sql5-sqlite libqt5test5 libqt5webchannel5 libqt5webkit5 libqt5xml5 libwoff1 mongodb-org-mongos mongodb-org-shell
  mongodb-org-tools python-apsw python-asn1crypto python-bs4 python-cffi-backend python-chardet python-cherrypy3 python-cryptography python-cssselect python-cssutils
  python-dateutil python-dbus python-dnspython python-enum34 python-feedparser python-html5-parser python-html5lib python-idna python-ipaddress python-libxml2 python-lxml
  python-markdown python-mechanize python-msgpack python-netifaces python-olefile python-openssl python-pil python-pygments python-pyparsing python-pyqt5 python-pyqt5.qtsvg
  python-pyqt5.qtwebkit python-regex python-repoze.lru python-routes python-simplejson python-sip python-six python-utidylib python-webencodings python-webob python-yaml
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  libcurl3 mongodb-org mongodb-org-server
The following NEW packages will be installed:
  libcurl4
0 upgraded, 1 newly installed, 3 to remove and 0 not upgraded.
Need to get 214 kB of archives.
After this operation, 61.6 MB disk space will be freed.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libcurl4 amd64 7.58.0-2ubuntu3 [214 kB]
Fetched 214 kB in 1s (419 kB/s)
(Reading database ... 235089 files and directories currently installed.)
Removing mongodb-org (4.0.0) ...
Removing mongodb-org-server (4.0.0) ...
Removing libcurl3:amd64 (7.58.0-2ubuntu2) ...
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 235068 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.58.0-2ubuntu3_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...

当我尝试安装 mongodb 时,libcurl4 将被删除

$ sudo apt install -y mongodb-org mongodb-org-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  calibre-bin fonts-mathjax geoclue-2.0 iio-sensor-proxy libbrotli1 libchm1 libgeoclue-2-0 libjs-coffeescript libjs-mathjax libpodofo0.9.5 libqt5designer5 libqt5help5
  libqt5positioning5 libqt5sensors5 libqt5sql5 libqt5sql5-sqlite libqt5test5 libqt5webchannel5 libqt5webkit5 libqt5xml5 libwoff1 python-apsw python-asn1crypto python-bs4
  python-cffi-backend python-chardet python-cherrypy3 python-cryptography python-cssselect python-cssutils python-dateutil python-dbus python-dnspython python-enum34
  python-feedparser python-html5-parser python-html5lib python-idna python-ipaddress python-libxml2 python-lxml python-markdown python-mechanize python-msgpack python-netifaces
  python-olefile python-openssl python-pil python-pygments python-pyparsing python-pyqt5 python-pyqt5.qtsvg python-pyqt5.qtwebkit python-regex python-repoze.lru python-routes
  python-simplejson python-sip python-six python-utidylib python-webencodings python-webob python-yaml
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libcurl3
The following packages will be REMOVED:
  libcurl4
The following NEW packages will be installed:
  libcurl3 mongodb-org mongodb-org-server
0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded.
Need to get 15.7 MB of archives.
After this operation, 61.6 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 libcurl3 amd64 7.58.0-2ubuntu2 [214 kB]
Get:2 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0/multiverse amd64 mongodb-org-server amd64 4.0.0 [15.5 MB]
Get:3 https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0/multiverse amd64 mongodb-org amd64 4.0.0 [3,518 B]                                                              
Fetched 15.7 MB in 25s (639 kB/s)                                                                                                                                                
(Reading database ... 235073 files and directories currently installed.)
Removing libcurl4:amd64 (7.58.0-2ubuntu3) ...
Selecting previously unselected package libcurl3:amd64.
(Reading database ... 235068 files and directories currently installed.)
Preparing to unpack .../libcurl3_7.58.0-2ubuntu2_amd64.deb ...
Unpacking libcurl3:amd64 (7.58.0-2ubuntu2) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../mongodb-org-server_4.0.0_amd64.deb ...
Unpacking mongodb-org-server (4.0.0) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_4.0.0_amd64.deb ...
Unpacking mongodb-org (4.0.0) ...
Setting up libcurl3:amd64 (7.58.0-2ubuntu2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up mongodb-org-server (4.0.0) ...
Setting up mongodb-org (4.0.0) ...

我该如何安装 curl 和 mongodb

答案1

解决库依赖问题的另一种方法是使用 docker 容器。

例如在这种情况下,一旦安装了 docker-ce,您可以运行如下命令:

docker run -d --name mongo-4.0.9  -p 127.0.0.1:27017:27017  --restart unless-stopped -v /var/lib/mongodb:/data/db mongo:4.0.9 

这样,您就不依赖于系统依赖项。

希望这可以帮助。

相关内容