cargo 编译 rust 错误解决方法

项目中一个代码库,之前编译是没有问题,最近出来新的错误

/rust$ sudo make
cd ../rust && \
        /usr/bin/python ./gen-c-headers.py && \
        CARGO_TARGET_DIR=/home/ics/liuys/dsa/dsa-probe/suricata/rust/target \
        CARGO_HOME=/home/ics/.cargo /usr/bin/cargo build --release  \
                --features "lua "
error: failed to download `autocfg v1.1.0`

Caused by:
  failed to enable HTTP2, is curl not built right?

Caused by:
  [1] Unsupported protocol

从现象上看是不只支持 http2 ,可是我用

curl --http2 -I https://nghttp2.org/

测试时没有问题的。

解决思路就像想 cargo 关闭 http2,于是到官网网站查手册

https://doc.rust-lang.org/cargo/reference/config.html

http.multiplexing

  • Type: boolean
  • Default: true
  • Environment: CARGO_HTTP_MULTIPLEXING

When true, Cargo will attempt to use the HTTP2 protocol with multiplexing. This allows multiple requests to use the same connection, usually improving performance when fetching multiple files. If false, Cargo will use HTTP 1.1 without pipelining.

于是执行

export CARGO_HTTP_MULTIPLEXING=false

又出现新的错误

error: failed to download from `https://crates-io.proxy.ustclug.org/api/v1/crates/build_const/0.2.2/download`

Caused by:
  [60] Peer certificate cannot be authenticated with given CA certificates (server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none)
Makefile:528: recipe for target 'all-local' failed
make: *** [all-local] Error 101

说明证书验证有问题,根据网上说法,关闭了 git 的证书检测也没有解决。然后通过系统命令更新CA证书解决

sudo apt update ; sudo apt-get install apt-transport-https ca-certificates -y ; sudo update-ca-certificates

sudo apt-get install apt-transport-https ca-certificates -y ; sudo update-ca-certificates
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libdbus-glib-1-2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  apt apt-utils libapt-pkg5.0 openssl
Suggested packages:
  apt-doc aptitude | synaptic | wajig
The following packages will be upgraded:
  apt apt-transport-https apt-utils ca-certificates libapt-pkg5.0 openssl
6 upgraded, 0 newly installed, 0 to remove and 437 not upgraded.
Need to get 2,988 kB of archives.
After this operation, 727 kB of additional disk space will be used.
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 libapt-pkg5.0 amd64 1.6.14 [809 kB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.14 [4,348 B]
Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 apt-utils amd64 1.6.14 [209 kB]
Get:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 apt amd64 1.6.14 [1,207 kB]
Get:5 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 openssl amd64 1.1.1-1ubuntu2.1~18.04.15 [614 kB]                                                      
Get:6 http://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/main amd64 ca-certificates all 20210119~18.04.2 [145 kB]                                                         
Fetched 2,988 kB in 12s (248 kB/s)                                                                                                                                               
Preconfiguring packages ...
(Reading database ... 108311 files and directories currently installed.)
Preparing to unpack .../libapt-pkg5.0_1.6.14_amd64.deb ...
Unpacking libapt-pkg5.0:amd64 (1.6.14) over (1.6.12) ...
Setting up libapt-pkg5.0:amd64 (1.6.14) ...
(Reading database ... 108311 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_1.6.14_all.deb ...
Unpacking apt-transport-https (1.6.14) over (1.2.24) ...
Preparing to unpack .../apt-utils_1.6.14_amd64.deb ...
Unpacking apt-utils (1.6.14) over (1.2.24) ...
Preparing to unpack .../archives/apt_1.6.14_amd64.deb ...
Unpacking apt (1.6.14) over (1.2.24) ...
Setting up apt (1.6.14) ...
Installing new version of config file /etc/apt/apt.conf.d/01autoremove ...
Installing new version of config file /etc/cron.daily/apt-compat ...
Installing new version of config file /etc/kernel/postinst.d/apt-auto-removal ...
(Reading database ... 108329 files and directories currently installed.)
Preparing to unpack .../openssl_1.1.1-1ubuntu2.1~18.04.15_amd64.deb ...
Unpacking openssl (1.1.1-1ubuntu2.1~18.04.15) over (1.0.2g-1ubuntu4.8) ...
Preparing to unpack .../ca-certificates_20210119~18.04.2_all.deb ...
Unpacking ca-certificates (20210119~18.04.2) over (20160104ubuntu1) ...
Setting up apt-transport-https (1.6.14) ...
Setting up apt-utils (1.6.14) ...
Setting up openssl (1.1.1-1ubuntu2.1~18.04.15) ...
Installing new version of config file /etc/ssl/openssl.cnf ...
Setting up ca-certificates (20210119~18.04.2) ...
Updating certificates in /etc/ssl/certs...
42 added, 87 removed; done.
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for ca-certificates (20210119~18.04.2) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.

然后 make ,顺利编译成功,搞定

你可能感兴趣的:(rust)