環境
- Windows 11
- VSCode
WSL2 と VSCode 拡張機能 インストール
WSL2 インストール
Windows ボタンを右クリックなどから、ターミナルを起動して、以下のコマンドを入力します。これだけで WSL2 と Ubuntu がインストールされます。
wsl --install
インストールが終わると Ubuntu が起動するので、ユーザー名とパスワードを設定します。

一旦、ログアウト(Ctrl+D)します。
VSCode に拡張機能をインストール
拡張機能をから WSL をインストールします。

VSCode から WSL 上の Ubuntu へ接続
VSCode のコマンドパレット(Ctrl+Shift+P)から WSL への接続を選択する。
Docker などをインストールしていると、他のディストリが起動することがある。その場合は下にあるディストリビューションを使用して WSL に接続を選択して Ubuntu を選択する。

接続が完了すると左下に「WSL:Ubuntu」と表示され、VSCode が参照するフォルダやターミナルが WSL 上の Ubuntu になる。

コメントを残す