今天使用vscode远程服务器的时候,突然报错如下
════════════╤════════════════════════════════════════════════════════════════════════╤════════════════════════════════════════════════════════════════════════╤════════════════════════════════════════════════════════════════════════╗
║ Status │ Message │ Mitigations │ Resources ║
╟──────────────┼────────────────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────────╢
║ LinuxPrereqs │ The remote host may not meet VS Code Server's prerequisites for glibc │ • https://aka.ms/vscode-remote/faq/old-linux │ • https://aka.ms/vscode-remote/linux-prerequisites ║
║ │ and libstdc++ (The remote host does not meet the prerequisites for │ │ ║
║ │ running VS Code Server)
一开始以为又是磁盘满了的情况,因为之前也遇到过ssh失败的时候,就是因为磁盘满了。但是上去看了下磁盘情况,发现空间还剩很多
[root@master ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 272M 7.5G 4% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 241G 72G 170G 30% /
/dev/sda1 1014M 289M 726M 29% /boot
既然磁盘没问题,那确认下是不是服务器上的code-server没起来,可能是版本不对,然后没下载对应的server版本。
bin目录下没有对应版本的目录,但是在.vscode-sever
目录下有code-19e0f9e681ecb8e5c09d8784acaa601316ca4571
,那我就想着手动执行看看,结果报错如下
[root@master ~]# ./.vscode-server/code-19e0f9e681ecb8e5c09d8784acaa601316ca4571
[2025-05-10 17:36:35] error This machine does not meet Visual Studio Code Server's prerequisites, expected either...
- find GLIBC >= v2.28.0 (but found v2.17.0 instead) for GNU environments
- find /lib/ld-musl-x86_64.so.1, which is required to run the Visual Studio Code Server in musl environments
结果出现了上述报错,看样子是glibc这个库版本不支持导致的。
https://code.visualstudio.com/docs/remote/linux#_remote-host-container-wsl-linux-prerequisites
Distribution | Base Requirements | Remote - SSH Requirements | Notes |
General | kernel >= 4.18, glibc >=2.28, libstdc++ >= 3.4.25, tar | OpenSSH server, , and or | Run to check the glibc version. Run to see if libstdc++ 3.4.25 is available. |
我的服务器是centos7,那只能把glibc给升级上去了
前置准备:gcc升级到4.9以上,make升级到4.0以上
我之前已经把gcc升级到8.5.0了,所以我只需要升级一下cmake版本
升级make到4.2.1。
我安装包是放在/opt/software目录,安装到/opt/module/make-4.2.1目录下,这个请根据实际需要修改
cd /opt/software
wget http://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz
tar -zxvf make-4.2.1.tar.gz
cd make-4.2.1
mkdir build
cd build
../configure --prefix=/opt/module/make-4.2.1 && make && make install
ln -s /opt/module/make-4.2.1/bin/make /usr/bin/make
rm /usr/bin/make
ln -s /opt/module/make-4.2.1/bin/make /usr/bin/make
rm /usr/bin/gmake
ln -s /opt/module/make-4.2.1/bin/make /usr/bin/gmake
make -v
附上升级gcc版本方法:
我安装包是放在/opt/software目录,安装到/opt/module/gcc-8.5.0目录下,这个请根据实际需要修改
cd /opt/software
wget https://ftp.gnu.org/gnu/gcc/gcc-8.5.0/gcc-8.5.0.tar.xz
xz -d gcc-8.5.0.tar.xz
tar -xvf gcc-8.5.0.tar
cd gcc-8.5.0
mkdir build
cd build
../configure --prefix=/opt/module/gcc-8.5.0 --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j4
make install
# 把gcc的可执行文件添加到环境$PATH中,要永久生效可以把下面命令写入 ~/.bash_rc或者/etc/profile中
export PATH="/opt/module/gcc-8.5.0/bin/:$PATH"
安装glibc2.28
cd /opt/software
wget https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.xz
xz -d glibc-2.28.tar.xz
tar -xvf glibc-2.28.tar
cd glibc-2.28
mkdir build
cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make -j4
make install
strings /lib64/libc.so.6 | grep GLIBC
后面重新使用vscode进行ssh连接就正常了。
如果vscode-sever下载比较慢的话,可以用下面的链接进行下载,然后解压放到 ~/.vscode-server/bin 目录下
https://vscode.download.prss.microsoft.com/dbazure/download/stable/${commit_id}/vscode-server-linux-x64.tar.gz
注意把:${commit_id}替换成对应的Commit ID