由于类型不匹配,sqlx 安装失败
sqlx installation fails due to mismatched types
我正在 Ubuntu 18.04 安装 sqlx:
cargo install --git https://github.com/launchbadge/sqlx sqlx-cli
我收到错误
error[E0308]: mismatched types
--> sqlx-cli/src/opt.rs:8:20
|
8 | #[clap(short = "D", long)]
| ^^^ expected `char`, found `&str`
$ rustc --explain E0308
Expected type did not match the received type.
Erroneous code example:
```
let x: i32 = "I am not a number!";
// ~~~ ~~~~~~~~~~~~~~~~~~~~
// | |
// | initializing expression;
// | compiler infers type `&str`
// |
// type `i32` assigned to variable `x`
```
This error occurs when the compiler is unable to infer the concrete type of a
variable. It can occur in several cases, the most common being a mismatch
between two types: the type the author explicitly assigned, and the type the
compiler inferred.
$ rustc --version
rustc 1.47.0 (18bf6b4f0 2020-10-07)
$ cargo --version
cargo 1.47.0 (f3c7e066a 2020-08-28)
如何解决错误并完成安装?
运行
cargo install -f --git https://github.com/launchbadge/sqlx sqlx-cli
而不是
cargo install --git https://github.com/launchbadge/sqlx sqlx-cli
修复了问题
我正在 Ubuntu 18.04 安装 sqlx:
cargo install --git https://github.com/launchbadge/sqlx sqlx-cli
我收到错误
error[E0308]: mismatched types
--> sqlx-cli/src/opt.rs:8:20
|
8 | #[clap(short = "D", long)]
| ^^^ expected `char`, found `&str`
$ rustc --explain E0308
Expected type did not match the received type.
Erroneous code example:
```
let x: i32 = "I am not a number!";
// ~~~ ~~~~~~~~~~~~~~~~~~~~
// | |
// | initializing expression;
// | compiler infers type `&str`
// |
// type `i32` assigned to variable `x`
```
This error occurs when the compiler is unable to infer the concrete type of a
variable. It can occur in several cases, the most common being a mismatch
between two types: the type the author explicitly assigned, and the type the
compiler inferred.
$ rustc --version
rustc 1.47.0 (18bf6b4f0 2020-10-07)
$ cargo --version
cargo 1.47.0 (f3c7e066a 2020-08-28)
如何解决错误并完成安装?
运行
cargo install -f --git https://github.com/launchbadge/sqlx sqlx-cli
而不是
cargo install --git https://github.com/launchbadge/sqlx sqlx-cli
修复了问题