VS Code Remote is a Remote development plug-in launched by Microsoft. It supports a variety of ways to connect to a Remote server directory for development

Shenzhen, due to the impact of the epidemic, we need to telecommute for two weeks. Considering the current research and development mode of separating the front and back ends, remote and local development should have no impact on the front end, but unfortunately, there are still some old projects based on THE DEVELOPMENT mode of PHP environment.

There are two ways to start

  • Plan 1: UseNFSMount to the company’s development directory
  • Solution 2: Access the development directory of the company by sharing files

You can use VS Code to access a shared or mounted development directory, but Git doesn’t work and file search doesn’t work. That’s why YOU want to try VS Code Remote

The operations described in this article focus on connecting a Mac (personal) to Linux (corporate server)

The installation

First, we need to install the extension Remote Development on our VS Code editor

This is an extension package, and the three plug-ins remote-WSL, remote-SSH and remote-containers will be installed at the same time with the installation. The functions of the three plug-ins are as follows:

  • Remote - SSH: SSH connects to virtual/physical Linux hosts
  • Remote - ContainersDocker can be connected to docker containers
  • Remote - WSL: Windows subsystem for Linux

You can also install the corresponding plug-ins according to your own needs

Use remote-SSH for connection

After installing the Remote plug-in, an area that connects to the Remote window appears in the lower left corner of the VS Code editor

Click on it and it comes up with a drop-down to connect, and we select

Enter username and host to confirm connection!

This needs to be configured and provided by the server side. Our company’s technical operation and maintenance team asks them to 🤩

There were two potholes:

Glibc and libstdc++ on the remote host do not meet VS Code Server requirements

The reason for this problem is that VS Code Server needs to be in CentOS 7 or later, while the remote host of the company is CentOS 6. Glibc and libstdc++ need to be upgraded. The specific upgrade is not expanded here, but you can Google it if necessary.

Because it is the server of the company, please operation and maintenance manager, the server based on CentOS 7, recreate an SSH, the connection is successful, the pit is filled

Second pit: Wget download failed

I don’t know why I need to download WGET and its function. If you know something, please let me know

Finally, our dear technology boss, Tonge, found the problem, the main reason is that our network export in Hong Kong, download resources in Australia, the speed is only 10KB /s, after the network export to Taiwan, the speed is up 😂.

Check online, found many people also encountered, issue address, can be referred to

After filling the above two pits, it really entered the stage of remote development 😄

The development of

The following picture shows the completed connection status, and the host of the server has been connected

Click open folder and select the file directory you want to develop

The git repository on the remote host shows 5K+ file changes, but no changes are found.

VS Code also has an official solution to this problem, suggesting that using the add.gitAttributes file for configuration is a better solution, and the Code can be synchronized to solve the problem for everyone

conclusion

Through VS Code Remote, we can directly connect to the server for development, but also solve the problem caused by NFS and file sharing, that is, git and file search cannot be used.

This practice, the client’s problem is not big, but for the concept of configuration and the response of the remote server, for a front-end engineer or have some difficulties, on the far side of a lot of problems are dependent on operational favorite assistance, or you may encounter when the first pit gave up, so we can have a career, but don’t have the technology.

Thanks to Dongge and Yangyang for their support and help 😘