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?

WSLで VS Code の使用を開始する

Posted at

Linux 用 Windows サブシステムで Visual Studio Code の使用を開始するを見ながらVS CodeからWSLで開発をできるようにしました。

Steps

0. 前提

  • Windows11 24H2
  • WSL-Ubuntu: 22.04.5 LTS
  • VS Code: 1.97.0
wsl version
> wsl --version
WSL バージョン: 2.4.10.0
カーネル バージョン: 5.15.167.4-1
WSLg バージョン: 1.0.65
MSRDC バージョン: 1.2.5716
Direct3D バージョン: 1.611.1-81528511
DXCore バージョン: 10.0.26100.1-240331-1435.ge-release
Windows バージョン: 10.0.26100.3037

一応、wsl --updateで最新にしています。

1. Remote Development 拡張機能パックインストール

VS CodeのRemote Development 拡張機能パックをインストール

2. Linux ディストリビューションを更新する

UbuntuでLinux ディストリビューションを更新。

sudo apt-get update
sudo apt-get install wget ca-certificates

3. Visual Studio Code で WSL プロジェクトを開く

Ubuntuでプロジェクトのディレクトリを適当に作り、そこをカレントディレクトリにして下記を実行。

fukuhara@fukuhara-yohei:~/repositories/HelloWorld$ code .
Installing VS Code Server for Linux x64 (33fc5a94a3f99ebe7087e8fe79fbe1d37a251016)
Downloading: 100%
Unpacking: 100%
Unpacked 2064 files and folders to /home/fukuhara/.vscode-server/bin/33fc5a94a3f99ebe7087e8fe79fbe1d37a251016.
Looking for compatibility check script at /home/fukuhara/.vscode-server/bin/33fc5a94a3f99ebe7087e8fe79fbe1d37a251016/bin/helpers/check-requirements.sh
Running compatibility check script
Compatibility check successful (0)

UbuntuでのVS Codeのインストールが始まり、インストールが終わると自動でVS Codeが起動。

使用

image.png
TERMINALは当然bashになっている。

Extensionもローカル(Windows)とWSLで区別されています
image.png

VS Codeのコマンド パレットを起動することで、より多くの VS Code の WSL オプションにアクセスすることもできます。 その後「WSL」と入力すると、利用できるオプションの一覧が表示されます。これにより、WSL セッションでフォルダーを開き直したり、開くディストリビューションを指定したりできます。

今回は試していませんがGitをWSLで使う方法のリンクです。

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?