起因
最新的vscode里面copilot插件更新了很多版本,而使用apt安装的vscode在ubuntu 18.04上最后的版本是1.85,从官网下载的deb包安装后报glibc错误
解决方法
1 下载vscode最新的压缩包
从 https://code.visualstudio.com/sha/download?build=stable&os=linux-x64下载最新的Linux安装包,解压,我的路径为~/software/VSCode-linux-x64
此时如果尝试用命令行启动该路径下的code,会报错。该错误会导致vscode每次都会弹出欢迎界面,不能读取保存某些设置数据
[main 2025-02-07T02:48:21.152Z] Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /home/jiang/software/VSCode-linux-x64/resources/app/node_modules/@vscode/sqlite3/build/Release/vscode-sqlite3.node)
at process.func [as dlopen] (node:electron/js2c/node_init:2:2559)
at Module._extensions..node (node:internal/modules/cjs/loader:1602:18)
at Object.func [as .node] (node:electron/js2c/node_init:2:2559)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/home/jiang/software/VSCode-linux-x64/resources/app/node_modules/@vscode/sqlite3/lib/sqlite3-binding.js:4:17)
at Module._compile (node:internal/modules/cjs/loader:1484:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/home/jiang/software/VSCode-linux-x64/resources/app/node_modules/@vscode/sqlite3/lib/sqlite3.js:2:17)
at Module._compile (node:internal/modules/cjs/loader:1484:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Module.load (node:internal/modules/cjs/loader:1295:32)
at Module._load (node:internal/modules/cjs/loader:1111:12)
at c._load (node:electron/js2c/node_init:2:16955)
at cjsLoader (node:internal/modules/esm/translators:350:17)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:286:7)
at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
从错误看是vscode里面的sqlite3插件采用了高版本的glibc编译,这里我决定自己从源代码编译该插件
2 编译vscode-node-sqlite3插件
打开github地址:https://github.com/microsoft/vscode-node-sqlite3
从release中下载最新的源代码,并解压到本地路径
终端进入该插件源代码路径,运行
pnpm i
等待构建好后,将该路径下的build/Release/vscode-sqlite3.node
替换vscode目录下的VSCode-linux-x64/resources/app/node_modules/@vscode/sqlite3/build/Release/vscode-sqlite3.node
文件
再次启动code就不会报错误了