0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WSL2+VSCode+DevcontainerでRust学習環境を一瞬で用意する

Posted at

Rustを学習するためにRustをインストール必要がありますが、本腰を入れて開発するわけでもないのに

するのは少し面倒だと感じました。なので、WSL2とDevcontainerをつかってRustを動かせる環境を構築してみます。なお、WSL2ではなくWindowsでもできますが、ファイルアクセスが遅くなるのでそのまま真似するのは推奨しません。

対象

  • Rust環境をサクッと用意したい人
  • Docker・コンテナ仮想化をある程度理解している人(Docker・Devcontaienr自体の解説はしません)

手順

  1. WSL2(今回はUbuntu on WSL2)上にDockerをインストールします(飛ばしてもDevcontainer使用時に自動でインストールされますが、経験上不安定になりがちなので手動インストール推奨です)
  2. Devcontainerの拡張機能をインストールします
  3. Rust学習用のディレクトリ(今回は~/Rust/)をつくり、VSCodeで開きます
    image.png
  4. コマンドパレット(Ctrl+Shift+P)を開き、開発コンテナー: コンテナーで再度開く(Reopen in Container)を選択します
    image.png
  5. インストールするツールとしてRustを選択します
    image.png
  6. そのあとの選択肢はEnter連打でOK(OSのバージョンや追加のツールなどを選択します)
  7. しばらく待つとコンテナ(Rustのツール一式が入った仮想OS)内に入れます
    image.png
  8. cargo(Rustのビルドシステム兼パッケージマネージャ)のバージョンを確認してみるとこんな感じ。Rust一式がインストールできていることがわかります
vscode ➜ /workspaces/Rust $ cargo --version
cargo 1.88.0 (873a06493 2025-05-10)
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?