Fix for "The engine exited with code 1 / Access is denied (0x80070005)" on Launch (v0.2.0) #9

Open
opened 2026-11-26 16:12:27 +00:00 by github-bot · 1 comment
Owner

@⁠Praisser on GitHub · 2026-11-26 16:11 UTC · original

Solution included below. This is the same bug as #2. Posting it as its own issue so people searching for the error find the fix. Pull requests are limited to collaborators, so the fix is in a fork.

Kelvaroq version

0.2.0 (built from 1270c42)

Hardware configuration

  • CPU: AMD Ryzen 7 6800H (8 cores / 16 threads)
  • GPU: NVIDIA GeForce RTX 3070 Laptop GPU (multi-GPU laptop with Radeon integrated graphics)
  • GPU driver version: 32.0.16.2101
  • VRAM: 8 GB
  • RAM: 16 GB (15.2 GiB usable)
  • OS (Windows version and build): Windows 11, build 26200
  • Display resolution: 1920×1080
  • Engine settings: Automatic, no VICTORY_* variables set

What happened?

Pressing Launch in the desktop workspace fails immediately and the game never starts:

The operation could not be completed.
The engine exited with code 1.
kelvaroq: ouverture du journal Windows: Access is denied. (0x80070005)

Running as administrator, Defender exclusions, folder permissions, and registering an event log source make no difference, because the error has nothing to do with the Windows event log or file permissions.

Cause

kelvaroq-desktop.exe starts kelvaroq-cli.exe with CreateNoWindow = true (Product.Command in src/launcher/App.cs), so the CLI already owns a hidden console. When launched from the workspace, native::run in src/native.rs calls AllocConsole() to open the log window. Windows returns ERROR_ACCESS_DENIED (0x80070005) when a process that already has a console calls AllocConsole(), and the launch stops there. phantom54 first pointed this out in #2.

How to fix it

Option 1: two-line code fix (recommended, keeps the full launcher). In src/native.rs, release the inherited console before opening the log window:

 use windows::{
-    Win32::System::Console::{AllocConsole, SetConsoleTitleW},
+    Win32::System::Console::{AllocConsole, FreeConsole, SetConsoleTitleW},
     core::w,
 };
 ...
         unsafe {
+            let _ = FreeConsole();
             AllocConsole().context("ouverture du journal Windows")?;

Then rebuild with cargo build --release --locked and replace kelvaroq-cli.exe in your Kelvaroq folder with the new target\release\kelvaroq.exe, renamed to kelvaroq-cli.exe. The rest of the package stays as it is.

The ready-made commit is here: github.com/Praisser/kelvaroq@e915c971c8 (branch fix/console-before-log on Praisser/kelvaroq).

Option 2: no rebuild (workaround from #2). Skip the workspace and start the game from PowerShell in the Kelvaroq folder:

.\kelvaroq-cli.exe play "<path to the game's .exe>"

This works because the CLI then has no hidden console. It skips what the workspace adds, though: shader preload, the Automatic hardware settings, and save snapshots.

Result after the fix

  • Before: Launch shows the error above, exit code 1, and no kelvaroq-engine.exe process starts.
  • After: Launch opens the log window, starts kelvaroq-engine.exe, and the game runs.

cargo test --locked --bin kelvaroq passes (15 tests).

Additional information

The fix commit doesn't carry the Co-authored-by: Moon AI trailer that checks.yml requires, since Moon AI wasn't involved in writing it. Maintainers can add their own trailer when applying it.

**@⁠Praisser** on GitHub · 2026-11-26 16:11 UTC · [original](https://github.com/stellarr-studio/kelvaroq/issues/9) > **Solution included below.** This is the same bug as #2. Posting it as its own issue so people searching for the error find the fix. Pull requests are limited to collaborators, so the fix is in a fork. ### Kelvaroq version 0.2.0 (built from `1270c42`) ### Hardware configuration - CPU: AMD Ryzen 7 6800H (8 cores / 16 threads) - GPU: NVIDIA GeForce RTX 3070 Laptop GPU (multi-GPU laptop with Radeon integrated graphics) - GPU driver version: 32.0.16.2101 - VRAM: 8 GB - RAM: 16 GB (15.2 GiB usable) - OS (Windows version and build): Windows 11, build 26200 - Display resolution: 1920×1080 - Engine settings: Automatic, no `VICTORY_*` variables set ### What happened? Pressing **Launch** in the desktop workspace fails immediately and the game never starts: ``` The operation could not be completed. The engine exited with code 1. kelvaroq: ouverture du journal Windows: Access is denied. (0x80070005) ``` Running as administrator, Defender exclusions, folder permissions, and registering an event log source make no difference, because the error has nothing to do with the Windows event log or file permissions. ### Cause `kelvaroq-desktop.exe` starts `kelvaroq-cli.exe` with `CreateNoWindow = true` (`Product.Command` in `src/launcher/App.cs`), so the CLI already owns a hidden console. When launched from the workspace, `native::run` in `src/native.rs` calls `AllocConsole()` to open the log window. Windows returns `ERROR_ACCESS_DENIED` (0x80070005) when a process that already has a console calls `AllocConsole()`, and the launch stops there. phantom54 first pointed this out in #2. ### How to fix it **Option 1: two-line code fix (recommended, keeps the full launcher).** In `src/native.rs`, release the inherited console before opening the log window: ```diff use windows::{ - Win32::System::Console::{AllocConsole, SetConsoleTitleW}, + Win32::System::Console::{AllocConsole, FreeConsole, SetConsoleTitleW}, core::w, }; ... unsafe { + let _ = FreeConsole(); AllocConsole().context("ouverture du journal Windows")?; ``` Then rebuild with `cargo build --release --locked` and replace `kelvaroq-cli.exe` in your Kelvaroq folder with the new `target\release\kelvaroq.exe`, renamed to `kelvaroq-cli.exe`. The rest of the package stays as it is. The ready-made commit is here: https://github.com/Praisser/kelvaroq/commit/e915c971c821ffc05f7cfe63e8a651c4d53a1a48 (branch `fix/console-before-log` on Praisser/kelvaroq). **Option 2: no rebuild (workaround from #2).** Skip the workspace and start the game from PowerShell in the Kelvaroq folder: ```powershell .\kelvaroq-cli.exe play "<path to the game's .exe>" ``` This works because the CLI then has no hidden console. It skips what the workspace adds, though: shader preload, the Automatic hardware settings, and save snapshots. ### Result after the fix - **Before:** Launch shows the error above, exit code 1, and no `kelvaroq-engine.exe` process starts. - **After:** Launch opens the log window, starts `kelvaroq-engine.exe`, and the game runs. `cargo test --locked --bin kelvaroq` passes (15 tests). ### Additional information The fix commit doesn't carry the `Co-authored-by: Moon AI` trailer that `checks.yml` requires, since Moon AI wasn't involved in writing it. Maintainers can add their own trailer when applying it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:12:27 +00:00
Author
Owner

@⁠gaxolotl on GitHub · 2026-11-26 17:10 UTC · original

Thanks.

**@⁠gaxolotl** on GitHub · 2026-11-26 17:10 UTC · [original](https://github.com/stellarr-studio/kelvaroq/issues/9#issuecomment-7198612962) Thanks.
This discussion has been locked. Commenting is limited to contributors.
No description provided.