我尝试通过 snap 以及 apt 安装 visual studio code,但两种情况下都没有用。点击后请参阅下面的跟踪code --verbose
。
其他观察 -
- 它的工作原理
sudo code --user-data-dir
并不正常。 - 当从应用程序->启动器图标尝试时,会出现空白窗口。
- 似乎不是
--disable-gpu
很多人面临的问题
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Failed to get 'appData' path
at App.l._setDefaultAppPaths (electron/js2c/browser_init.js:17:1420)
at Object.<anonymous> (electron/js2c/browser_init.js:217:2440)
at Object../lib/browser/init.ts (electron/js2c/browser_init.js:217:3716)
at __webpack_require__ (electron/js2c/browser_init.js:1:128)
at electron/js2c/browser_init.js:1:1200
at electron/js2c/browser_init.js:1:1267
at NativeModule.compile (internal/bootstrap/loaders.js:287:5)
at NativeModule.compileForPublicLoader (internal/bootstrap/loaders.js:222:8)
at loadNativeModule (internal/modules/cjs/helpers.js:23:9)
at Module._load (internal/modules/cjs/loader.js:745:15)
/usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so: undefined symbol: g_date_time_format_iso8601
Failed to load module: /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so
[15861:1112/150521.850343:ERROR:gl_surface_glx.cc(90)] glXGetFBConfigs failed.
[15861:1112/150521.850568:ERROR:gl_surface_glx.cc(130)] Failed to get GLXConfig
[15861:1112/150521.850684:ERROR:gl_surface_glx.cc(479)] CreateDummyWindow(gfx::GetXDisplay()) failed
[15861:1112/150521.850761:ERROR:gl_initializer_x11.cc(148)] GLSurfaceGLX::InitializeOneOff failed.
[15861:1112/150521.854457:WARNING:x11_util.cc(1520)] X error received: serial 218, error_code 8 (BadMatch (invalid parameter attributes)), request_code 78, minor_code 0 (X_CreateColormap)
[15861:1112/150521.854938:ERROR:viz_main_impl.cc(152)] Exiting GPU process due to errors during initialization
我尝试了很多方法,但都没有成功。 帮助!
输出apt-cache policy gvfs:*; readelf -s /usr/lib/x86_64-linux-gnu/gio/modules/libgvfsdbus.so | grep g_date_time ; snap info --verbose code
gvfs:
Installed: 1.44.1-1ubuntu1
Candidate: 1.44.1-1ubuntu1
Version table:
*** 1.44.1-1ubuntu1 500
500 http://in.archive.ubuntu.com/ubuntu focal/main amd64 Packages
100 /var/lib/dpkg/status
gvfs:i386:
Installed: (none)
Candidate: 1.44.1-1ubuntu1
Version table:
1.44.1-1ubuntu1 500
500 http://in.archive.ubuntu.com/ubuntu focal/main i386 Packages
6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND g_date_time_unref
265: 0000000000000000 0 FUNC GLOBAL DEFAULT UND g_date_time_new_now_local
463: 0000000000000000 0 FUNC GLOBAL DEFAULT UND g_date_time_format_iso860
name: code
summary: Code editing. Redefined.
health:
status: unknown
message: health has not been set
publisher: Visual Studio Code (vscode✓)
store-url: https://snapcraft.io/code
contact: https://twitter.com/code
license: unset
description: |
Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and
is available for Linux, macOS and Windows. It comes with built-in support for JavaScript,
TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++,
C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity).
By downloading and using Visual Studio Code, you agree to the license terms
(https://code.visualstudio.com/License/) and privacy statement
(https://privacy.microsoft.com/en-us/privacystatement). Visual Studio Code automatically sends
telemetry data and crash dumps to help us improve the product. If you would prefer not to have
this data sent please go see
https://code.visualstudio.com/docs/supporting/FAQ#_how-to-disable-crash-reporting to learn how to
disable it.
VSCode
https://github.com/Microsoft/vscode
commands:
- code
- code.url-handler
notes:
private: false
confinement: classic
devmode: false
jailmode: false
trymode: false
enabled: true
broken: false
ignore-validation: false
snap-id: Ht0aUHi7ofh9Fbwh6m7jUN2pAy6kzBiu
tracking: latest/stable
refresh-date: today at 15:04 IST
channels:
latest/stable: e5a624b7 2020-11-11 (50) 153MB classic
latest/candidate: ↑
latest/beta: ↑
latest/edge: ↑
installed: e5a624b7 (50) 153MB classic
答案1
在网上搜索了 4 到 6 个小时后,发现问题与 HOME 环境变量有关,该变量被错误设置,将/root
其更改为/home/your_username
,然后就可以正常工作了。
指示-
/home/your_username
从(不是/root
)打开 .bashrc 文件- 将其添加到最后一行 -
export HOME=/home/your_username
- 重新启动计算机或执行
source .bashrc
答案2
这有效:
先尝试
$ code --disable-gpu
否则
$ code --disable-gpu --disable-software-rasterizer