
Remote development in VS Code: your life will never be the same
- Transfer
In our TestMace Visual Studio Code is one of the most popular tools. And it is all the more encouraging that it is developing by leaps and bounds. Your attention is invited to translate an article about another tasty feature, which is available only in VS Code Insiders.
I agree, I went too far with the headline, I just overwhelmed with emotions. I decided to share my first impressions of the remote development in VS Code , at the time of writing, available in VS Code Insiders.
Extensions for remote development require the installation of Visual Studio Code Insiders .
The possibility of remote development in Visual Studio Code is the ability to use a container, a remote computer, or the Windows Subsystem for Linux (WSL) as a complete development environment. At the same time, the whole process is divided into two parts: the client part of the application runs on the local computer, and the VS Code server is almost anywhere. The extension kit for remote development includes three extensions. The following three articles will help you study each of them in more detail:
- Remote - SSH - access to any directory on a remote or virtual machine using SSH.
- Remote - Containers - work with an isolated set of tools or containerized applications inside a container (or mounted in a container).
- Remote - WSL - application development in the Windows Subsystem for Linux (WSL).
I will give a concrete example. Suppose you need to develop an application in any language, but your computer does not have the language itself, nor the SDK, nor the necessary tools.
Many developers writing for Windows create Windows virtual machines in the cloud, and then connect to the desktop via RDP and steer windows. In this case, the virtual machine performs all related operations. Linux developers create Linux virtual machines or containers and connect to them via SSH through the terminal, launch vim or tmux and write to the console. In this case, the virtual machine performs all related operations. In both scenarios, the client-server connection is not implemented, but the interaction of the terminal or thin client with the server. VS Code is a fat client with a clear and understandable interface of language services and location transparency.
When you write code - for example, an instance of an object, and after the dot character (.), You automatically complete the names of the contents of this object. Who does this work? Where does this list come from? If the code is run locally, and even in the container, you need to make sure that both sides (client and server) are synchronized, use the same SDK and the like. Not an easy task.
Suppose Rust is not installed on your computer and the necessary development tools.
Then we clone the following repository:
git clone https://github.com/Microsoft/vscode-remote-try-rust
Launch VS Code Insiders:
C:\github> git clone https://github.com/Microsoft/vscode-remote-try-rust
Cloning into 'vscode-remote-try-rust'...
Unpacking objects: 100% (38/38), done.
C:\github> cd .\vscode-remote-try-rust\
C:\github\vscode-remote-try-rust [main =]> code-insiders .
Then VS Code asks if you want to open this container.
The devcontainer.json file contains a list of extensions required for the current project. The VS Code extensions will be installed in the Docker container, and then they can be used remotely. Your local system does not need all of them at all, it is enough to install only those that you plan to use in the current project. Of course, you can do without installing anything on your local computer, but the golden mean is to get rid of unnecessary manual configuration of the system.
Take a look at the screenshot below. Here the tools you need are added to the dockerfile, the Docker executable is launched, and we see the VS Code server!
Go to the Extensions section in VS Code and pay attention to the lower left corner. The green status bar indicates that client-server interaction has been implemented. All necessary Rust extensions are installed in the container and are ready for use in VS Code. The entire installation process took a matter of minutes.
By editing the code in this way, you get the same functions of autocompletion, debugging, and more.
Here is an example of a real-time application debugging session on Rust that does not require any configuration other than installing VS Code Insiders, Remote Extensions, and Docker (which I already had).
As I said, you can run code using WSL, in containers, or through SSH . This style of development is only gaining momentum. It is simple and straightforward, and it is very interesting for me to watch where this leads us. We have to perform so many routine tasks , and remote editing of the code allows us to throw out everything superfluous from the development process and focus on the most important thing.