vscode
vscode copied to clipboard
fix: improve Wayland detection and environment setup
Overview This PR fixes the Wayland detection and environment setup issues when launching browsers through xdg-open in VS Code.
Issue
When running xdg-open commands from VS Code's integrated terminal under Wayland sessions, users encounter the error:
"Failed to open Wayland display, fallback to X11"
Fixes #229096
Changes
- Fixed Wayland socket path detection by using correct XDG_RUNTIME_DIR path
- Added proper GDK_BACKEND environment setup
- Added Wayland-specific environment variables for browser compatibility
- Maintained X11 fallback when Wayland is not available
Testing Notes This change requires a Linux system running a Wayland session to test. I have tested the changes on Fedora 40 with:
- Wayland session (XDG_SESSION_TYPE=wayland)
- VS Code 1.91.1
- Firefox as default browser
The fix can be verified by:
- Running VS Code in a Wayland session
- Opening the integrated terminal
- Running
xdg-open https://www.google.es - Verifying the browser opens without the "Failed to open Wayland display" error