Skip to content

fix: mcp failed+wayland nvidia fallback on Linux #7278

Open
endermeme wants to merge 7 commits intojanhq:mainfrom
endermeme:fix/mcp-failed+wayland-nvidia-fallback
Open

fix: mcp failed+wayland nvidia fallback on Linux #7278
endermeme wants to merge 7 commits intojanhq:mainfrom
endermeme:fix/mcp-failed+wayland-nvidia-fallback

Conversation

@endermeme
Copy link
Copy Markdown

@endermeme endermeme commented Dec 23, 2025

Describe Your Changes

Fix 2 critical Linux startup errors:

  1. MCP config error on fresh installs
    Error: Failed to run mcp commands: Failed to read config file: No such file or directory (os error 2)
    Fix: Create default mcp_config.json if missing, refactor with load_or_create_mcp_config helper

  2. NVIDIA Wayland graphics crash
    Error: Failed to create GBM buffer of size 1024x800: Invalid argument
    Fix: Disable DMABUF renderer, add wayland,x11 fallback, set NVIDIA env vars

Changes:

  • src-tauri/src/core/mcp/helpers.rs: Add config file creation logic
  • src-tauri/src/lib.rs: Add Linux graphics compatibility env vars

(My first PR ever! Please excuse any rookie mistakes. Thanks for your patience and review! :D)

@endermeme endermeme changed the title Fix/mcp failed+wayland nvidia fallback on Linux fix: mcp failed+wayland nvidia fallback on Linux Dec 23, 2025
@tokamak-pm
Copy link
Copy Markdown

tokamak-pm Bot commented Mar 31, 2026

Code Review

Summary

Two fixes: (1) MCP auto-creates mcp_config.json on first launch instead of failing, and (2) Linux graphics environment variables for Wayland/NVIDIA fallback. Also includes unrelated .gitignore replacement and yarn.lock changes.

Key Findings

  • MCP fix is solidload_or_create_mcp_config is a clean refactor that correctly handles the first-launch scenario. Test is updated appropriately.
  • NVIDIA env var issue__GLX_VENDOR_LIBRARY_NAME=nvidia is set unconditionally for all Linux users, even without NVIDIA GPUs. This will attempt to load the NVIDIA vendor library on AMD/Intel systems, potentially causing failures. Must be guarded behind NVIDIA detection.
  • WEBKIT_DISABLE_DMABUF_RENDERER=1 and GDK_BACKEND=wayland,x11 are correct for the stated Wayland/NVIDIA issue.
  • Unrelated changes.gitignore replacement and yarn.lock modifications don't belong in this PR.

Recommendation: fix needed

Guard __GLX_VENDOR_LIBRARY_NAME=nvidia behind NVIDIA GPU detection or remove it. Drop the unrelated .gitignore and yarn.lock changes.

@tokamak-pm
Copy link
Copy Markdown

tokamak-pm Bot commented Apr 23, 2026

Code Review -- PR #7278: fix: mcp failed+wayland nvidia fallback on Linux

Summary

This PR addresses two Linux startup issues:

  1. MCP config: Adds a load_or_create_mcp_config helper that auto-creates a default mcp_config.json when the file is missing on fresh installs.
  2. NVIDIA Wayland graphics crash: Sets environment variables (WEBKIT_DISABLE_DMABUF_RENDERER, GDK_BACKEND, __GLX_VENDOR_LIBRARY_NAME) at startup on Linux to avoid GBM buffer errors.

Positive

  • The MCP config helper is a clean refactor -- it deduplicates read/parse logic from run_mcp_commands and add_server_config_with_path, and the auto-creation of a default config is a good UX improvement.
  • The test was properly updated from asserting failure to asserting successful auto-creation.
  • Environment variable fallbacks respect existing user-set values via is_err() checks.

Issues

1. src-tauri/.gitignore overwrite (fix needed)
The src-tauri/.gitignore has been completely replaced with what appears to be a copy of the root-level .gitignore. The new content includes paths like docs/yarn.lock, website/dist/, autoqa/, etc. that are meaningless relative to the src-tauri/ directory. Critically, it now ignores Cargo.lock and target without the leading /, and removes the important binaries ignore rules with their exceptions. This file should be reverted to the original, or at minimum only have intentional changes.

2. Unrelated yarn.lock / dependency changes
The diff includes extensions/yarn.lock hash changes and removals of react-joyride and related packages from the root yarn.lock. These are unrelated to the MCP/Wayland fix and should be in a separate PR.

3. NVIDIA vendor library name assumption
Setting __GLX_VENDOR_LIBRARY_NAME=nvidia unconditionally on Linux when the variable is unset may cause issues for users with AMD/Intel GPUs. This env var tells the GLX loader to prefer the NVIDIA vendor library, which could cause rendering failures on non-NVIDIA systems. Consider detecting NVIDIA hardware first, or removing this line entirely since it is NVIDIA-specific and not a safe default.

4. std::env::set_var is unsafe in Rust 2024+
std::env::set_var is marked as unsafe starting in Rust edition 2024. Depending on the project's edition target, this may need to be wrapped in an unsafe block or an alternative approach should be used.

Recommendation: fix needed

The .gitignore overwrite and unrelated dependency changes must be cleaned up. The NVIDIA env var assumption should be revisited.

@tokamak-pm
Copy link
Copy Markdown

tokamak-pm Bot commented Apr 24, 2026

PR Review: fix: mcp failed + wayland nvidia fallback on Linux

Summary of Changes

Fixes two Linux startup errors:

  1. MCP config missing on fresh install: Adds load_or_create_mcp_config helper that creates a default mcp_config.json if it does not exist, preventing the "No such file or directory" error.
  2. NVIDIA Wayland graphics crash: Sets environment variables at startup to disable the DMA-BUF renderer and configure Wayland/X11 fallback for NVIDIA GPUs.

Additional changes:

  • Refactored add_server_config_with_path to use the new helper.
  • Updated tests to verify auto-creation behavior.
  • Replaced the src-tauri/.gitignore with a much larger, project-root-style gitignore.
  • Removed react-joyride and related dependencies from yarn.lock.
  • Changed extensions/yarn.lock checksums.

Key Findings

Correctness

  • The load_or_create_mcp_config helper is well-implemented: creates parent directories, writes a valid default config, and returns the parsed value.
  • The test update correctly validates the auto-creation behavior instead of asserting a failure.

Risks

  • __GLX_VENDOR_LIBRARY_NAME=nvidia forced globally: Setting this unconditionally on all Linux systems (not just NVIDIA) could cause issues on AMD/Intel GPU systems. The comment says "NVIDIA-specific optimization" but the guard only checks if the env var is already set, not whether the user actually has an NVIDIA GPU. Consider detecting the GPU vendor first, or at minimum document this behavior.
  • WEBKIT_DISABLE_DMABUF_RENDERER=1: Disabling DMA-BUF globally may degrade performance on systems where it works correctly. This is a broad workaround for an NVIDIA-specific issue.
  • GDK_BACKEND=wayland,x11: This is reasonable as a fallback chain but may override user preferences on X11-only setups.
  • .gitignore replacement: The src-tauri/.gitignore is replaced with what appears to be a copy of the project root .gitignore. This includes entries like docs/yarn.lock, website/dist/, autoqa/ which are irrelevant inside src-tauri/. The original .gitignore was compact and targeted. This change should be reverted or trimmed to only relevant entries.
  • Unrelated yarn.lock / extensions/yarn.lock changes: The removal of react-joyride and lockfile checksum changes appear unrelated to the MCP/Wayland fixes and should be in a separate PR.
  • std::env::set_var in unsafe context: On recent Rust editions, set_var is considered unsafe in multithreaded contexts. Since this runs at startup before Tauri initializes, it should be fine, but be aware of future Rust edition warnings.

Tests

  • The updated test for test_add_server_config_missing_config_file now correctly validates the auto-creation path and verifies the written content. Good improvement.

Recommendation: fix needed

The MCP config auto-creation fix is clean and correct. However:

  1. The .gitignore replacement in src-tauri/ should be reverted to the original targeted version.
  2. The NVIDIA env vars should either be gated on actual GPU detection or clearly documented as potentially affecting non-NVIDIA systems.
  3. The unrelated yarn.lock changes should be removed from this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants