Clap compile error

Hi, I have been working on a program using clap and I found the compilation refuse to work any more. After series of debugging I decided to create a new helloworld binary and add this to cargo.toml:

[dependencies]
clap = { version = "3.1.5", features = ["derive"] }

And cargo keeps saying :

error: unknown start of token: \u{0}
 --> /home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.3.2/src/lib.rs:1:188
  |
1 | ...ine]
  | ^
  |
  = help: source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used

changing the dependencies to the following do the same.

clap="3.1.5"

I have never met this before, so I wonder if the environment goes wrong? Or I add the dependencies wrongly?
Thank you for any thoughts!

Delete that folder (/home/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.3.2). And then run it again. It may fix the problem.

1 Like

Oh it did solve the problem, many thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.