sqlx安装由于类型不匹配而失败

问题描述

我正在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)

The full logs

如何解决错误并完成安装?

GitHub issue

解决方法

运行

import fileinput

string1 = "text substring text substring text substring text" #this string is in the text file "file_containing_string1"
list1 = [element1,element2,element3]

...

with fileinput.FileInput(file_containing_string1,inplace = True,backup = ".bak") as file:

    for element in list1:

        for line in file:
            line = line.replace("substring",element,1)
            print(line,end = "")

代替

cargo install -f --git https://github.com/launchbadge/sqlx sqlx-cli

解决了问题

source

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...