M1Mac에서 coc-rust-analyzer의 일부가 작동하지 않을 때
현상.
coc.nvim extension의coc-rust-analyzer에서 일부 코드가 도약을 정의할 수 없는 현상이 발생했습니다.
예:
#[derive(Debug, StructOpt)]
#[structopt(global_settings = &[AppSettings::ColoredHelp])]
pub struct Args {
#[structopt(short="j", long="json")]
pub json: bool,
}
fn main() {
// このfrom_argsから定義ジャンプしようとしてもnot foundになる
let mut args = Args::from_args();
}
이때 사용하는rust-analyzer는coc-rust-analyzer를 넣은 후 기본적으로 다운로드하는 버전을 사용합니다.VScode에서 VScode에서 다운로드한rust-analyzer를 사용하여 점프를 정의하는 데 문제가 없습니다.
:CocCommand rust-analyzer.serverVersion
에서 rust-analyzer 버전 보기[coc.nvim] rust-analyzer 65fbe0a8d 2022-04-18 stable
.원인의 특정
coc에서 기본적으로 설치된rust-analyzer 이외의rust-analyzer를 사용합니다
VScode 확장부터 rust-analyzer가
~/.vscode/extensions/matklad.rust-analyzer{バージョン名}/server/rust-analyzer
의 경로에 들어갔습니다.이것 괜찮아요?nvim부터 사용.
coc-settings.json
{
"rust-analyzer.server.path": "~/.vscode/extensions/matklad.rust-analyzer-0.2.1022-darwin-arm64/server/rust-analyzer"
}
이 설정을 시도하면 점프를 문제 없이 정의할 수 있습니다.마찬가지로 Releases · rust-lang/rust-analyzer에서 상기한coc-rust-analyzer에서 설치한rust-analyzer와 같은 버전의rust-analyzer-arch64-apple-darwin을 설치했다.gz 해동을 다운로드하여coc독서도 순조롭게 진행될 수 있습니다.
안에 있는 거 봐.
rust-analyzer를 설치한 것 같다이 파일.
M1Mac에 어떤 영향을 미칠지 찾아보면
downloader.ts
function getPlatform(): string | undefined {
const platforms: { [key: string]: string } = {
'ia32 win32': 'x86_64-pc-windows-msvc',
'x64 win32': 'x86_64-pc-windows-msvc',
'x64 linux': 'x86_64-unknown-linux-gnu',
'x64 darwin': 'x86_64-apple-darwin',
'arm64 win32': 'aarch64-pc-windows-msvc',
'arm64 linux': 'aarch64-unknown-linux-gnu',
'arm64 darwin': 'aarch64-apple-darwin',
};
let platform = platforms[`${process.arch} ${process.platform}`];
if (platform === 'x86_64-unknown-linux-gnu' && isMusl()) {
platform = 'x86_64-unknown-linux-musl';
}
return platform;
}
이 함수는 매우 의심스럽기 때문에, 우선 node의process입니다.arch는 M1Mac으로 무엇을 되돌려 검증을 시도합니다.$ node -p process.arch
x64
...알겠습니다.상술한 getPlatform()
함수는 되돌아올 수 있다x86_64-apple-darwin
.물론 조개껍질로arch 지령을 두드리면 정확한 구조가 나타난다.
$ arch
arm64
process.arch
node 버전에 따라 무엇을 되돌려 줍니까? node 버전을 바꾸어 보세요.참고로 상술한 명령 시간은 v14입니다.19.1 사용합니다.
다음 단계는 node16에서 실행됩니다.
$ node -v
v16.14.2
$ node -p process.arch
arm64
예상대로 노드 버전이 원인입니다.대응법
전역 버전을 node16 이상으로 고정하고coc에서 시작하는rust-analyzer를 다시 설치합니다.
설치된
~/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer
중 있으므로 삭제해야 합니다.rm ~/.config/coc/extensions/coc-rust-analyzer-data/rust-analyzer
이후 :CocRestart
,:CocCommand rust-analyzer.reload
,Vim 재부팅 등의 이유로 coc-rust-analyzer는 다음과 같은 정보를 보내고 이에 따라 설치한다.rust-analyzer is not found, download from GitHub release?:
1. Yes
2. Cancel
Type number and <Enter> or click with the mouse (q or empty cancels):
설치 후 정의 점프가 정상적으로 작동합니다.coc-rust-analyzer가 이런 현상에 대한 홍보를 할 것 같지만process.arch를 사용하지 않으면 더러운 코드로 대응해야 한다는 예감이 들었기 때문에 문서에 상응하는 현상과 대응 방법을 남기고 싶은 issue에서도 고려해 주십시오.
시험을 준비하다
node 15.5.1 이후 버전은 괜찮을 거예요.
volta pin node@14
로컬 노드 버전을 고정시키기로 했습니다.Reference
이 문제에 관하여(M1Mac에서 coc-rust-analyzer의 일부가 작동하지 않을 때), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/kbwok/articles/coc-rust-analyzer-m1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)