Cannot create a project with cargo


#1

Hi,
I have just installed Rust on Msys2 with mingW. It took me 2 days :).
I can compile the example hello_world.rs but when I tried to create project hello_cargo with cargo using command

cargo new hello_cargo --bin

I got error:

Thang@Thang-Laptop MINGW64 /c/Users/Thang/rust_projects
$ cargo new hello_cargo --bin
error: Failed to create project `hello_cargo` at `C:\Users\Thang\rust_projects\hello_cargo`

Caused by:
  Couldn't load Cargo configuration

Caused by:
  could not parse TOML configuration in `C:\Users\Thang\.cargo\config`

Caused by:
  could not parse input as TOML

Caused by:
  invalid escape character in string: `m` at line 2

I follow a link online to create a config file with content below

Thang@Thang-Laptop MINGW64 /c/Users/Thang/.cargo
$ cat config
[target.x86_64-pc-windows-gnu]
linker = "c:\msys64\mingw64\bin\gcc.exe"
ar = "c:\msys64\mingw64\bin\ar.exe"

Look like I miss something relates to TOML configuration. I know that I have to create a toml file inside the project but at this step I just create the project folder template only.

Did I miss anything?

Thanks in advance.


#2
  invalid escape character in string: `m` at line 2

TOML treats \s as escapes, not paths, so you’ll need "c:\\msys64… etc.


#3

It works, thank you very much :slight_smile: