【问题标题】:Cargo error: unable to get packages from source货物错误:无法从源头获取包裹
【发布时间】:2022-01-25 23:20:00
【问题描述】:
error: failed to download `adler v1.0.2`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/home/actionanand/.cargo/registry/src/github.com-1ecc6299db9ec823/adler-1.0.2/Cargo.toml`
Caused by:
could not parse input as TOML
Caused by:
unexpected character found: `\u{0}` at line 1 column 1
我们添加新依赖时,Rust .toml 文件满是红线
【问题讨论】:
标签:
rust
webassembly
rust-cargo
【解决方案1】:
这是由于内部包裹(比如货物)崩溃引起的
我们可以按照以下步骤解决这个问题
- 请清货
registry
rm -rf /home/username/.cargo/registry/
- 如果您使用旧版本,请按照后面显示的步骤操作
作为参考,我在下面也给出了程序:
If you are trying to migrate from the previous edition (2018), the
process requires following these steps:
1. Start with `edition = "2018"` in `Cargo.toml`
2. Run `cargo fix --edition`
3. Modify `Cargo.toml` to set `edition = "2021"`
4. Run `cargo build` or `cargo test` to verify the fixes worked
More details may be found at
https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html
您有时可能需要添加--allow-no-vcs(终端会提示)如下
cargo fix --edition --allow-no-vcs