- æ¦è¦
- WSLã«ã¦ç¾å¨å®è¡ãã¦ãããã®ãä¸è¦§åºå
- WSLã«ã¦ç¹å®ã®ã¤ã¡ã¼ã¸ãã¤ã³ãã¼ããã
- ä½ã£ãä»®æ³ãã·ã³ãåæ¢ãããå ´å
- ä½ã£ãä»®æ³ãã·ã³ãåé¤ãããå ´å
- ä½ã£ãä»®æ³ãã·ã³ãã¨ã¯ã¹ãã¼ããããå ´å
- WSLãå©ç¨ããã¡ã¢ãªéãå¶éãããå ´å
- ä¸è¬ã¦ã¼ã¶ã®ä½æ
- ä»®æ³ãã·ã³ã«ç¹å®ã®ã¦ã¼ã¶ã§ãã°ã¤ã³ãã
- ãã±ã¼ã«ã調æ´ãã
- Cè¨èªã®ç°å¢ãä½ã
- Pythonã®ç°å¢ãä½ã
- Goã®ç°å¢ãä½ã
- dotnetã®ç°å¢ãä½ã
- Java ã®ç°å¢ãä½ã
- Javaã§Spring Bootã®ç°å¢ãä½ã
- Flutterã®ç°å¢ãä½ã
- PowerShell (pwsh) ã®ç°å¢ãä½ã
- åèè³æ
æ¦è¦
æè¿ã¯ãdocker ã¨ãã§ç°å¢æ§ç¯ãããããã®ãããã©ã«ãã«ãªã£ã¦ããããããã¾ããããWSL2ã¨VSCodeã®çµã¿åãããã¨ã¦ã便å©ãªã®ã§ãå人çã«ã¯ããå©ç¨ãã¦ãã¾ãã
WSLé¢é£ã®è¨äºãè¦ã¦ããã¨ã大æµã¹ãã¢ããUbuntuãã¤ã³ã¹ãã¼ã«ããããã¦å©ç¨ãããã¿ã¼ã³ãå¤ãã¨æãã¾ãããäºã rootfs ã®ã¤ã¡ã¼ã¸ãç¨æãã¦ãã㦠wsl ã«ã¤ã³ãã¼ããããã¨ãåºæ¥ã¾ãã(éã«ã¨ã¯ã¹ãã¼ããå¯è½ã§ã)
ãã®ããæ¹ã ã¨ãä½åãä»®æ³ãã·ã³ããµã¯ãµã¯å ¥ãããã¨ãã§ããã®ã§ãã¨ã¦ã楽ã§ãã
以ä¸ãèªåç¨ã®ã¡ã¢ã§ããããã¤ããã£ã¦ããããæ¹ã§ãã
ä»åå ¥ããã®ã¯ãUbuntu 21.04 ã®ã¯ã©ã¦ãã¤ã¡ã¼ã¸ã使ãã¾ãããµã¤ãºã 450MB ããããªã®ã§çµæ§è»½ãã
ã¤ã¡ã¼ã¸ã¯ãããããã¦ã³ãã¼ãå¯è½ã§ãã
ãã¡ã¤ã«åã« wsl.rootfs ã¨ä»ãã¦ãããã®ããWSLåãã®ã¤ã¡ã¼ã¸ã¨ãªã£ã¦ãã¾ãã
WSLã«ã¦ç¾å¨å®è¡ãã¦ãããã®ãä¸è¦§åºå
以ä¸ã®ã³ãã³ãã§è¡¨ç¤ºã§ãã¾ãã
> wsl -l -v
WSLã«ã¦ç¹å®ã®ã¤ã¡ã¼ã¸ãã¤ã³ãã¼ããã
wsl ã³ãã³ãã§ãã¤ã³ãã¼ãããã«ã¯ä»¥ä¸ã®ããã«ã³ãã³ããå®è¡ãã¾ãã
> wsl --import åå <ã¤ã¡ã¼ã¸ãã¡ã¤ã«ãé ç½®ãããå ´æ> <ã¤ã¡ã¼ã¸ãã¡ã¤ã«ã®ãã¹>
ä¾ãã°ãååã myenv
ã§ãã¤ã¡ã¼ã¸ãã¡ã¤ã«ã®é
ç½®å ´æã c:\data\wsl\myenv
ãã¤ã¡ã¼ã¸ãã¡ã¤ã«ã®ãã¹ã c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz
ã ã¨ããã¨ä»¥ä¸ã®ããã«ãªãã¾ãã
> wsl --import myenv c:\data\wsl\myenv c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ä½ã£ãä»®æ³ãã·ã³ãåæ¢ãããå ´å
以ä¸ã®ããã« wsl ã³ãã³ããå®è¡ããã¨åæ¢ããã¾ãã
> wsl -t åå
ä½ã£ãä»®æ³ãã·ã³ãåé¤ãããå ´å
以ä¸ã®ããã« wsl ã³ãã³ããå®è¡ããã¨åé¤ããã¾ãã
> wsl --unregister åå
ä½ã£ãä»®æ³ãã·ã³ãã¨ã¯ã¹ãã¼ããããå ´å
以ä¸ã®ããã« wsl ã³ãã³ããå®è¡ããã¨ã¨ã¯ã¹ãã¼ãããã¾ãã
> wsl --export ã¨ã¯ã¹ãã¼ãããä»®æ³ãã·ã³ã®åå <ã¨ã¯ã¹ãã¼ãå ã®ãã¹ (æ¡å¼µå㯠tar ã§)>
ã¨ã¯ã¹ãã¼ããããã¡ã¤ã«ã¯ãwsl --import
ã§æ®éã«ã¤ã³ãã¼ãå¯è½ã§ãã
ãªã®ã§ãåºæ¬è¨å®ãããã¡ã¤ã«ãã¨ã¯ã¹ãã¼ããã¦ããã¨ããã¤ã§ãã¤ã³ãã¼ãå¯è½ã«ãªãã¾ãã
WSLãå©ç¨ããã¡ã¢ãªéãå¶éãããå ´å
ä¸è¬ã¦ã¼ã¶ã®ä½æ
ä¸è¨ã®ããæ¹ã§ä»®æ³ãã·ã³ãä½ãã¨ãroot ã¦ã¼ã¶ã§ãã°ã¤ã³ãããã¨ã«ãªãã¾ãã
èªåã®ãã¹ãç°å¢ãªã®ã§æ§ããªãã¨ããæ¹ã¯ãã®ã¾ã¾å©ç¨ããã°ããã¨ãããã¾ããããã£ã±ãä¸è¬ã¦ã¼ã¶ãããã£ã¦æ¹ã¯ä»¥ä¸ã§ã¦ã¼ã¶ãä½æãã¦ããã¾ãããã
# useradd -m -s $(which bash) new-user-name # passwd new-user-name # usermod -G sudo new-user-name
ããã©ã«ãã§ã¯ãä»ããWindowsã®ãã£ã¬ã¯ããªãåæãã¹ã¨ãã¦èµ·åãã¾ãã
ãããå«ãªå ´åã¯ã以ä¸ã .bashrc
ã¨ãã«è¿½å ãã¦ãããããããã¾ããã
# echo 'cd ~' >> /home/new-user-name/.bashrc
ã§ãä¸æ¦ä»®æ³ãã·ã³ãããã°ã¢ã¦ããã¦ã以ä¸ã®ããã«ã¦ã¼ã¶ãæå®ãã¦å ¥ãã¾ãã
# exit > wsl -d xxx-env -u new-user-name
ä»®æ³ãã·ã³ã«ç¹å®ã®ã¦ã¼ã¶ã§ãã°ã¤ã³ãã
ããã©ã«ãã§ã¯ã¦ã¼ã¶ãæå®ããªã㨠root ã§ãã°ã¤ã³ãããã¨ã«ãªãã¾ãã
ã¦ã¼ã¶ãæå®ããå ´åã¯ä»¥ä¸ã®ããã«ãã¾ãã
> wsl -d xxx-env -u user-name
ããã©ã«ãã¦ã¼ã¶ãå¤æ´ãããå ´åã¯ä»¥ä¸ãåç §ãã ããã
ãã±ã¼ã«ã調æ´ãã
å¿ è¦ã§ããã°ããã±ã¼ã«ãæ¥æ¬èªã«ãã¾ãã
# ä»ã®ãã±ã¼ã«ãç¢ºèª $ locale LANG=C.UTF-8 LANGUAGE= LC_CTYPE="C.UTF-8" LC_NUMERIC="C.UTF-8" LC_TIME="C.UTF-8" LC_COLLATE="C.UTF-8" LC_MONETARY="C.UTF-8" LC_MESSAGES="C.UTF-8" LC_PAPER="C.UTF-8" LC_NAME="C.UTF-8" LC_ADDRESS="C.UTF-8" LC_TELEPHONE="C.UTF-8" LC_MEASUREMENT="C.UTF-8" LC_IDENTIFICATION="C.UTF-8" LC_ALL=
ãã±ã¼ã«ãããã©ã«ãã§ã¯ C.UTF-8
ã«ãªã£ã¦ãã¾ããããã ja_JP.UTF8
ã«ããã«ã¯ä»¥ä¸ã®ããã«ãã¾ãã
$ sudo apt -y install language-pack-ja $ sudo apt -y install manpages-ja manpages-ja-dev $ sudo update-locale LANG=ja_JP.UTF8
manpageã¯ãªãã±ã§ãããã®å¾ãä¸åWSL2ããåºã¦ãã¤ã¡ã¼ã¸ãåèµ·åãã¦ããã¾ãã
$ exit > wsl -t xxxx > wsl -d xxxx
ãã±ã¼ã«ãå¤ãã£ããã©ããã確èª
$ locale LANG=ja_JP.UTF8 LANGUAGE= LC_CTYPE="ja_JP.UTF8" LC_NUMERIC="ja_JP.UTF8" LC_TIME="ja_JP.UTF8" LC_COLLATE="ja_JP.UTF8" LC_MONETARY="ja_JP.UTF8" LC_MESSAGES="ja_JP.UTF8" LC_PAPER="ja_JP.UTF8" LC_NAME="ja_JP.UTF8" LC_ADDRESS="ja_JP.UTF8" LC_TELEPHONE="ja_JP.UTF8" LC_MEASUREMENT="ja_JP.UTF8" LC_IDENTIFICATION="ja_JP.UTF8" LC_ALL=
Cè¨èªã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import c-env c:\data\wsl\c-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d c-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
å¿ è¦ãªãã®ãã¤ã³ã¹ãã¼ã«
$ apt install -y gcc gdb make cmake valgrind zip unzip
ããã§ãã³ã³ãã¤ã©ãªã©ã¯ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
Pythonã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import python-env c:\data\wsl\python-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d python-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
python3 ã¯æåããå ¥ã£ã¦ããã®ã§ãããã venv ãã¦å©ç¨ããæãã§ã
$ python3 Python 3.9.4 (default, Apr 4 2021, 19:38:44) [GCC 10.2.1 20210401] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
Ubuntuãªã®ã§ãpipã¨venvãå¥éã¤ã³ã¹ãã¼ã«
$ apt install python3-pip python3-venv make zip unzip
ããã§ãå¿ è¦ãªãã®ã¯ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
Goã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import golang-env c:\data\wsl\golang-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d golang-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
Goã®SDKãã¤ã³ã¹ãã¼ã«
$ apt install golang make zip unzip
ããã§ãã³ã³ãã¤ã©ãªã©ã¯ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
dotnetã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import dotnet-env c:\data\wsl\dotnet-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d dotnet-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
dotnetã®SDKãã¤ã³ã¹ãã¼ã«
$ wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb $ sudo dpkg -i packages-microsoft-prod.deb $ sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-5.0 $ sudo apt install -y make zip unzip
ããã§ãã³ã³ãã¤ã©ãªã©ã¯ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
Java ã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import java-env c:\data\wsl\java-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d java-env
ä¸è¬ã¦ã¼ã¶ã®ä½æã¨ããã©ã«ãã¦ã¼ã¶ã®å¤æ´
$ useradd -m -s $(which bash) new-user $ passwd new-user $ usermod -G sudo new-user $ cat << EOF > /etc/wsl.conf [user] default=new-user EOF
ä¸æ¦ãä»®æ³ãã·ã³ãåæ¢ããä½ã£ãä¸è¬ã¦ã¼ã¶ã§å ¥ãç´ãã
$ exit > wsl -t java-env > wsl -d java-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ sudo apt update -q; sudo apt upgrade -yq
OpenJDKãã¤ã³ã¹ãã¼ã«
$ sudo apt install -y zip unzip make $ curl -s "https://get.sdkman.io" | bash $ source "$HOME/.sdkman/bin/sdkman-init.sh" $ sdk install java 11.0.11.hs-adpt
ããã§ãã³ã³ãã¤ã©ãªã©ã¯ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
Javaã§Spring Bootã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import springboot-env c:\data\wsl\springboot-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d springboot-env
ä¸è¬ã¦ã¼ã¶ã®ä½æã¨ããã©ã«ãã¦ã¼ã¶ã®å¤æ´
$ useradd -m -s $(which bash) new-user $ passwd new-user $ usermod -G sudo new-user $ cat << EOF > /etc/wsl.conf [user] default=new-user EOF
ä¸æ¦ãä»®æ³ãã·ã³ãåæ¢ããä½ã£ãä¸è¬ã¦ã¼ã¶ã§å ¥ãç´ãã
$ exit > wsl -t springboot-env > wsl -d springboot-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
Spring Bootã®SDKãã¤ã³ã¹ãã¼ã«
$ apt install -y zip unzip make $ curl -s "https://get.sdkman.io" | bash $ source "$HOME/.sdkman/bin/sdkman-init.sh" $ sdk install java 11.0.11.hs-adpt $ sdk install springboot $ . ~/.sdkman/candidates/springboot/current/shell-completion/bash/spring
ããã§ãã³ã³ãã¤ã©ãªã©ã¯ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
Flutterã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import flutter-env c:\data\wsl\flutter-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d flutter-env
ä¸è¬ã¦ã¼ã¶ã®ä½æã¨ããã©ã«ãã¦ã¼ã¶ã®å¤æ´
$ useradd -m -s $(which bash) new-user $ passwd new-user $ usermod -G sudo new-user $ cat << EOF > /etc/wsl.conf [user] default=new-user EOF
ä¸æ¦ãä»®æ³ãã·ã³ãåæ¢ããä½ã£ãä¸è¬ã¦ã¼ã¶ã§å ¥ãç´ãã
$ exit > wsl -t flutter-env > wsl -d flutter-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
Flutter ã®åä½ã«å¿ è¦ãªããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«
$ apt install -y zip unzip libglu1-mesa make
Flutter ã® SDK ãã¤ã³ã¹ãã¼ã«
$ cd /usr/local $ git clone https://github.com/flutter/flutter.git -b stable $ cd bin $ ln -s /usr/local/flutter/bin/dart dart $ ln -s /usr/local/flutter/bin/flutter flutter
dartã¨flutterãã¡ããã¨åãã確èª
$ dart version $ flutter version
Flutter ãæ´æ°
$ flutter upgrade $ flutter doctor
flutter doctor
ããã¨ãããã¤ã¹ãä½ãç¡ãç¶æ
ã ãã©ãweb-server ã§ã¯èµ·åãã¦éã¹ãã®ã§ãå人çã«ã¯ããã§ãªã±ã
flutter config 㧠android 㨠ios ã¯ç¡å¹ã«ãã¦ãã
flutter config --enable-web flutter config --no-enable-android flutter config --no-enable-ios
ããã§æºåã¯ãªãã±ã¤ãå¾ã¯
$ flutter create app $ cd app $ flutter run -d web-server
ã¨ããã°èµ·åããã
å¾ã¯ VSCode å´ã§éã¶ã
$ code .
ããã§ãVSCode ããã®ä»®æ³ãã·ã³ã«æ¥ç¶ããç¶æ ã§èµ·åããã®ã§ãå¾ã¯å¥½ãã«ã§ããã
è£è¶³
WSL2ã®ç°å¢ã§Android SDKãã»ããã¢ããããããæ¹ãæ¸ãã¦ãã ãã£ã¦ãè¨äºãããã¾ãããæè¬ã
PowerShell (pwsh) ã®ç°å¢ãä½ã
æåã«ã¤ã³ãã¼ããã¦ã綺éºãªç©ºã®ç°å¢ãç¨æ
> wsl --import pwsh-env c:\data\wsl\pwsh-env c:\data\rootfs\hirsute-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
ã¤ã³ãã¼ããçµãã£ãããèµ·å
> wsl -d pwsh-env
ããã±ã¼ã¸ã®ç¶æ ãææ°ã«æ´æ°
$ apt update -q; apt upgrade -yq
ä¸è¬ã¦ã¼ã¶ã®ä½æ
$ useradd -m -s $(which bash) new-user-name $ passwd new-user-name $ usermod -G sudo new-user-name
ä¸æ¦ãã°ã¢ã¦ããã¦ãä¸è¬ã¦ã¼ã¶ã§å ¥ãç´ãã
$ exit > wsl -d pwsh-env -u new-user-name
PowerShell ã®ã¤ã³ã¹ãã¼ã«
$ sudo apt-get update $ sudo apt-get install -y wget apt-transport-https software-properties-common $ wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb $ sudo dpkg -i packages-microsoft-prod.deb $ sudo apt-get update $ sudo add-apt-repository universe $ sudo apt-get install -y powershell $ sudo apt install -y make zip unzip $ rm packages-microsoft-prod.deb $ pwsh PowerShell 7.1.3 Copyright (c) Microsoft Corporation. https://aka.ms/powershell Type 'help' to get help. PS /home/xxx>
åèè³æ
https://cloud-images.ubuntu.com/hirsute/current/cloud-images.ubuntu.com
éå»ã®è¨äºã«ã¤ãã¦ã¯ã以ä¸ã®ãã¼ã¸ãããåç §ä¸ããã
- ããããåå¿é²æ¥è¨ã¾ã¨ã
ãµã³ãã«ã³ã¼ãã¯ã以ä¸ã®å ´æã§å ¬éãã¦ãã¾ãã
- ããããåå¿é²æ¥è¨ãµã³ãã«ã½ã¼ã¹ç½®ãå ´