remrin

remrin

github
email

Fix the remote host does not meet the prerequisites for running the VS Code server

Problem#

You are right, but this remote host may not meet the prerequisites for glibc and libstdc++ VS Code server.

image

Introduction#

Since version 1.99 of VS Code (around March 2025), the official VS Code has set new requirements for its pre-built server running environment on Linux systems: the target system must have glibc version 2.28 or higher. This means that modern distributions like Debian 10, RHEL 8, or Ubuntu 20.04 can be seamlessly supported, but it does pose some challenges for users still using some classic Linux distributions (like CentOS 7). Detailed official instructions can be found in this FAQ.

Fortunately, Microsoft has left a window open.

If a sysroot containing the required library versions is provided, VS Code still allows users to connect to unsupported operating systems (operating systems with glibc version not greater than 2.28 and libstdc++ version not greater than 3.4.25) via the Remote - SSH extension. This method gives you and your organization more time to migrate to newer Linux distributions.

Suitable Situations for This Tutorial#

The system is CentOS 7.9 / RHEL 7.9 / Oracle Linux 7.9 / Ubuntu 18.04, and the server does not have root privileges, and you do not want to revert to version 1.98.

::: warning
This is just a technical workaround and not an officially supported usage scenario. Please consider carefully before use.
:::

Detailed Step-by-Step Guide#

Based on this background, I discovered the vscode-sysroot project. The project essentially uses Docker and the crosstool-ng tool to compile a sysroot that includes glibc 2.28 and is compatible with older kernel versions (e.g., 3.10). It also includes patchelf. This perfectly fits my current situation, so I directly used this project.

1. Prepare Docker Environment#

First, please ensure that the local environment or server has Docker installed and running successfully. This is the basis for compiling the sysroot.

2. Build Sysroot Archive#

Next, clone the vscode-sysroot repository, which will be used to compile and generate the sysroot archive.

git clone https://github.com/ursetto/vscode-sysroot.git
cd vscode-sysroot

The project provides two build methods:

Build Docker Image#

docker build -t my-vscode-sysroot .

Create a Temporary Container#

docker create --name temp-sysroot-container my-vscode-sysroot

Copy the Generated Archive from the Container's /src Directory to the Current Host Directory#

docker cp temp-sysroot-container:/src/vscode-sysroot-x86_64-linux-gnu.tgz ./vscode-sysroot-x86_64-linux-gnu.tgz

Remove Temporary Container#

docker rm temp-sysroot-container

(Optional) If You Want to Enter the Container for Debugging or Inspection#

docker run -it --rm my-vscode-sysroot bash

3. Deploy the Packaged Sysroot to the Server#

Upload Sysroot Archive#

First, upload the vscode-sysroot-x86_64-linux-gnu.tgz file to the server. You can use scp or other file transfer tools:

scp ./vscode-sysroot-x86_64-linux-gnu.tgz user@your-remote-server:~

Extract Sysroot#

Log in to the remote server, then execute the following commands to create the target directory and extract the sysroot. The path is ~/.vscode-server/sysroot/

# Execute on the remote server
mkdir -p ~/.vscode-server/sysroot
# Assuming the archive has been uploaded to the user's home directory ~
tar zxvf ~/vscode-sysroot-x86_64-linux-gnu.tgz -C ~/.vscode-server/sysroot --strip-components=1

Tip: The --strip-components=1 parameter in the tar command is to handle any extra top-level directories that may exist inside the archive. If you find that the file path has an extra layer after extraction (e.g., ~/.vscode-server/sysroot/vscode-sysroot-x86_64-linux-gnu/usr/...), then you need this parameter. If after extraction, directories like usr, lib, etc., are directly under ~/.vscode-server/sysroot/, you can omit it or set the value to 0.

Deploy sysroot.sh Script#

Then, copy the sysroot.sh script from the root directory of the vscode-sysroot project to the ~/.vscode-server/ directory on the remote server, ensuring it is named sysroot.sh:

# Execute on the local machine (ensure you are in the root directory of the vscode-sysroot project)
scp sysroot.sh user@your-remote-server:~/.vscode-server/sysroot.sh

Configure Shell Environment#

To ensure that the VS Code Server automatically loads the prepared sysroot environment upon startup, you need to add a line in the shell configuration file on the remote server (usually ~/.bashrc or ~/.zshrc, depending on the shell you are using) to source sysroot.sh:

# Execute on the remote server
echo 'source ~/.vscode-server/sysroot.sh' >> ~/.bashrc
# If you are using zsh, change it to:
# echo 'source ~/.vscode-server/sysroot.sh' >> ~/.zshrc

After modifying and saving, remember to reload the configuration file or simply log back into the server to make the settings take effect:

# Execute on the remote server
source ~/.bashrc
# Or source ~/.zshrc

4. Connect and Verify#

Reopen VS Code and connect to the remote server; it should be ready without issues.

This article is synchronized and updated to xLog by Mix Space Original link is https://remrin.dev/posts/dev/vscode-remote-fix

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.