LoginSignup
2
2

More than 1 year has passed since last update.

Windowsでrust-analyzerをエラーなく使うには

Last updated at Posted at 2021-10-06

前提

筆者はrust初心者です。

背景

WindowsでRustいれてRust開発しようかなと思って、vscodeにrust-analyzerを入れたはいいが、
以下のようなエラーになってしまう。あとなんかすごい重いので、対策に乗り出した。
image.png

cargo check failed:
error: failed to run custom build command for `openssl-sys` v0.9.63

Caused by:
 process did'nt exit ....
..
..(省略)
..
note: vcpkg did not find openssl: Could not find Vcpkg tree:...

やったこと

vcpkgのインストール

https://github.com/Microsoft/vcpkg#quick-start-windows このリポジトリをcloneして、bootstrap-vcpkg.bat を実行する。

bootstrap-vcpkg.bat

終わったら、vcpkg.exeが作成されるので、そのフォルダへのパスを通しておく。

その後、VCPKG_ROOTという環境変数名で登録する。

Visual Studioに英語の言語パックのインストール

自分の環境の場合は、Visual Studio2019だったが、以下で必要なopensslのvcpkg経由でのインストールに英語の言語パックが必要らしいので、インストールする(Visual Studio2017のBuild Toolだった。ここは個々の環境で違うかも)

Visual Studio Installerを開いて、言語パックのタブを選択→英語の言語パックをインストールする。

opensslのインストール

vcpkg経由でインストールする。かなり時間かかる。15分くらい。

vcpkg.exe install openssl:x64-windows-static-md

まとめ

  • 今回初めてvcpkgを触ってみたが、いろいろ罠がある感じだった。
  • rust-analyzerにかなり障壁があった
  • 簡単なhello worldレベルではrust-analyzerのエラーにならなかったので、なんか他の要因もあるのかもしれない。参照しているクレートの関係か?
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2