使用Cargo时,我们非常熟悉以下错误。
[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file /Users/calvin/tiflash/raft-engine/Cargo.toml, Some(Version { major: 1, minor: 64, patch: 0, pre: Prerelease("nightly") }): Failed to run `"cargo" "metadata" "--format-version" "1" "--manifest-path" "/Users/calvin/tiflash/raft-engine/Cargo.toml" "--filter-platform" "x86_64-apple-darwin"`: `cargo metadata` exited with an error: Updating git repository `https://github.com/pingcap/rust-protobuf`
Updating git repository `https://github.com/tikv/raft-rs`
error: failed to load source for dependency `raft-proto`
Caused by:
Unable to update https://github.com/tikv/raft-rs?branch=master
Caused by:
failed to fetch into: /Users/calvin/.cargo/git/db/raft-rs-42b8049ef2e3af07
Caused by:
failed to authenticate when downloading repository: git@github.com:tikv/raft-rs
* attempted ssh-agent authentication, but no usernames succeeded: `git`
if the git CLI succeeds then `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
no authentication available
通过使用以下命令,可以解决问题
eval `ssh-agent -s`
ssh-add
但是,在使用vscode的同时,我们如何做到这一点呢?一种方法是使用命令行启动vscode,但这是一个不是很整洁的解决方案。
我想知道vscode或rust-analyzer插件中是否有一些配置可以帮助。
1条答案
按热度按时间mccptt671#
我发现修改
~/.cargo/config
会有所帮助。