Recently, when I wrote a mall back-end demo in rust, I downloaded a lot of external dependency packages through crates.io due to the interaction with mysql and serialization. In the process, I encountered the problem of version change and different versions between mirror sites, as described below.
Problem Description and Resolution
1. Dependent Package Adaptation Problems Due to Version Change
Some error codes are as follows:
error[E0308]: mismatched types --> /home/hadoop/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.4.6/src/atof/algorithm/bigcomp.rs:243:55 | 243 | let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1); | ^^^^^^^^^^^^^^^ expected `usize`, found `u32` error[E0277]: no implementation for `usize & u32` --> /home/hadoop/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.4.6/src/atof/algorithm/bigcomp.rs:243:53 | 243 | let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1); | ^ no implementation for `usize & u32` | = help: the trait `BitAnd<u32>` is not implemented for `usize` error[E0308]: mismatched types --> /home/hadoop/.cargo/registry/src/github.com-1ecc6299db9ec823/lexical-core-0.4.6/src/atof/algorithm/bigcomp.rs:261:40 | 261 | let (q, r) = shift.ceil_divmod(Limb::BITS); | ^^^^^^^^^^ expected `usize`, found `u32` |
The external package where errors can be found is lexical_core-0.4.6, at first I modified the code in the package and found it ineffective, so I started to query Official Crates.io Documentation . After consulting the specific documentation and version updates for the lexical-core package, I know that the latest version of the external package has been updated to version 0.8.2, and the package downloaded from the mirror site has lagged behind significantly.
That's one reason for the problem. Secondly, before I query the official Crates.io document, I also modified the code, such as u32:BITS-1 to usize:BITS-1, but the error did not change. So I also queried the cargo version, and I checked the author's version (1.55.0) Official Documents Read and find the following for BITS:
pub const BITS: u32 The size of this integer type in bits. Examples assert_eq!(u32::BITS, 32);
pub const BITS: u32 The size of this integer type in bits. Examples assert_eq!(usize::BITS, 64);
So the code will not be valid until you modify it.
After changing the Crates.io mirror source address and running the code again, there was an error: Could not find directory of OpenSSL installation, while my ubuntu20.04 had the latest version of openssl installed, and finally at Here A solution to the problem was found:
Mac OSX / Homebrew If you have Homebrew installed: $ brew install firstname.lastname@example.org Debian / Ubuntu Using the apt package manager: $ apt install pkg-config libssl-dev Fedora / RHEL / CentOS And using yum: $ pkg-config openssl-devel Or with the newer dnf package manager: $ dnf install pkg-config openssl-devel
At this point, all temporary problems will be solved.
First of all, because Rust is not so mainstream as python and other languages, it is difficult to find solutions to errors on general websites and blogs. This has forced me to start reading the official documentation notes, which are both a challenge and a growth, as well as a habit of relying on official documentation.
Secondly, because I installed the rust compilation environment using the handover source, but updated the Crates.io mirror source simply replaced the SCADA source, without considering the adaption between different mirror sources. For example, in the process of replacing the mirror source, the author found that the versions provided by different mirror source websites are inconsistent with the lexical-core external package mentioned above. So it caused serious errors in the production process.
Finally, through this experience, the author has grown up, but also more skilled in the use of some methods. Thank you for your reading. If you have any questions or corrections, please do not hesitate to give us your advice.