I use Windows 10 and you can do this without a VM.
Install Windows Subsystem Linux 2 Ubuntu:
Install Visual Studio 2 Insiders which allows you to code in your Windows 10 Environment to your Ubuntu Environment. VSCode Insiders is a different application then VSCode, so your default VSCode should remain unchanged.
Open a Command Prompt [Windows]
Type wsl and now you should be in the Ubuntu Terminal
Ok, so the main release of VSCode lets you do this now too (you might need to close VSCode after the first run and then run code . again). So thanks Rick, between these two guides all Windows devs should be covered.
You’ll know you’re connected when you can see WSL at the bottom left of the VSCode application window. You can always start and manage WSL connections from here too.
You might be getting errors with canister installs on WSL version 1 (the current non-insider build). It seems that the VSCode WSL server holds onto files while open. Killing the server frees the files up and canister installs run fine then, you can do this by closing the WSL connection from the bottom left of VSCode.
WSL v2 is in the next public Windows 10 build, expected in the next few weeks, which hopefully should resolve this.
This is also possible to create dfx docker container and use it everywhere you need.
Download dfx’s install.sh
Remove or comment these lines from it (explained below):
#need_cmd sudo
#if ! confirm_license; then
# echo "Please accept the license to continue."
# exit
#fi
Make a Dockerfile with something like this:
FROM ubuntu:18.04
RUN apt-get update
RUN apt-get install curl -y
COPY install.sh install.sh
RUN sh install.sh
WORKDIR /root/dfx
ENTRYPOINT ["/usr/local/bin/dfx"]
Then just use docker run with correct mounting
Unfortunately, to make it work, we should remove lines responsible for showing the license agreement, which we are not allowed to remove legally. So please, don’t use this method unless you know what are you doing. Why should we remove these lines? Because the agreement is interactive but docker doesn’t support interactive build. So we are absolutely not allowed to share a docker image like this.
Maybe, it is possible to make legally correct docker image by including licence agreement process into Dockerfile itself (each time you run the container you should accept the agreement). This approach makes the license agreement a little annoying, but let’s anyone use dfx under any system supporting docker and also keeps it’s legal strength IMO.
I’m not a lawyer, just saying that from technical point of view this can be achieved easily.
Just make sure you work off the Linux home location. There are some issues when the location of the projects is on the mounted drives mapped to the Windows home location.