As a developer, dealing with an IDE that crashes on startup is incredibly frustrating. Visual Studio Code (VS Code) is a popular choice, so when it fails to work, productivity can take a hit. Recently, I encountered this issue on Ubuntu, and here's how I resolved it.
The Problem
When launching Visual Studio Code, it would load the project and then immediately close. This unexpected behavior was particularly annoying, and it seemed surprising that such a critical issue slipped through Microsoft's quality control.
What Caused the Crash?
The problem started after I disabled hardware acceleration in the $HOME/.vscode/argv.json
file. I made this change because VS Code was running extremely slow on my Ubuntu setup, which I suspected was due to Nvidia drivers.
Here's how to get some info about your graphic card
hwinfo --gfxcard --short
graphics card:
nVidia GP108M [GeForce MX150]
Intel UHD Graphics 620
Primary display adapter: #24
How to Check Your Video Card Drivers
This may have been caused by nvidia drivers. Not sure and didn't have time to fully troubleshoot.
Before diving into fixes, ensure that your Nvidia drivers are up to date. Run the following command in your terminal (as root):
ubuntu-drivers autoinstall
The solution to prevent VS Code from crashing
I uninstalled it and reinstalled it and then found this parameter that fixed the issue and code doesn't crash anymore. Maybe the reinstallation wasn't necessary but I found about it after I uninstalled it.
code --in-process-gpu .
It will produce a warning: Warning: 'in-process-gpu' is not in the list of known options, but still passed to Electron/Chromium. but it will start.
Links
these are the links I checked during the troubleshooting.
- https://ubuntu.com/server/docs/nvidia-drivers-installation
- https://www.cyberciti.biz/faq/ubuntu-linux-install-nvidia-driver-latest-proprietary-driver/
- https://github.com/microsoft/vscode/issues/212494
- https://stackoverflow.com/questions/63070794/my-vs-code-keeps-crashing-when-opening-it
- https://www.linuxbabe.com/ubuntu/install-nvidia-driver-ubuntu