Skip to content

fix(ui): load config before reading the path cvars it can set - #384

Open
Azkali wants to merge 1 commit into
rexglue:developmentfrom
Azkali:fix/config-load-before-path-cvars
Open

fix(ui): load config before reading the path cvars it can set#384
Azkali wants to merge 1 commit into
rexglue:developmentfrom
Azkali:fix/config-load-before-path-cvars

Conversation

@Azkali

@Azkali Azkali commented Jul 21, 2026

Copy link
Copy Markdown

Fixes #383.

Summary

ReXApp::SetupEnvironment() read the four path cvars (game_data_root, user_data_root, update_data_root, cache_path) and baked them into PathConfig before rex::cvar::LoadConfig() ran, so a value set in the TOML could never influence path resolution — the cvar still held its empty default at the moment it was read.

This resolves the default config path up front and loads it before those reads.

Why this is safe

The default config path is exe_dir / (GetName() + ".toml") — derived purely from the executable folder and the app name, with no dependency on any cvar. So loading it first cannot become circular, which is presumably why it was placed later in the first place.

OnConfigurePaths() may still redirect config_path, so the existing load is kept for exactly that case, now guarded on the path having actually changed to avoid applying the same file twice.

Ordering, before and after

before after
resolve default config path line 111 (inside PathConfig) up front, line 79
load config line 123 line 83
read game_data_root etc. lines 81-104 after the load
load redirected config only if OnConfigurePaths changed it

The comment that was on line 121 (// Load config FIRST so log cvars have final values) was accurate for the logging setup below it, but the call sat under every path cvar read — so "FIRST" only held relative to logging.

Test plan

  • Builds clean at v0.8.0 + this patch.
  • Ordering verified by reading e8ce24f; the bug is platform-independent (no arch-specific behaviour involved).
  • Confirm game_data_root set in the TOML is now honoured with no command-line argument.
  • Confirm passing --game_data_root on the command line still wins where both are present, and that a config redirected by OnConfigurePaths still applies.

Notes

Independent of the aarch64 work in #381/#382 — this one reproduces anywhere, no special hardware needed. Submitted as its own issue + PR per the one-at-a-time request.

@Azkali
Azkali requested a review from tomcl7 as a code owner July 21, 2026 13:37
@Graine25

Copy link
Copy Markdown
Member

Formatting looks alright. Can you send this to the development branch?

@Azkali

Azkali commented Jul 22, 2026

Copy link
Copy Markdown
Author

Formatting looks alright. Can you send this to the development branch?

Sure no problem !

@Azkali
Azkali force-pushed the fix/config-load-before-path-cvars branch from f8f5eb0 to 0793608 Compare July 22, 2026 05:41
@Azkali
Azkali changed the base branch from main to development July 22, 2026 05:42
ReXApp::SetupEnvironment() read game_data_root / user_data_root /
update_data_root / cache_root / metadata_root via REXCVAR_GET at the top
of the function, but rex::cvar::LoadConfig(config_path_) did not run
until after PathConfig had already been built from those values. A value
set in the TOML config therefore could not influence path resolution:
the cvar still held its default (empty) when it was read.

The visible result is that setting game_data_root in the config file has
no effect and the app aborts with '--game_data_root was not provided.'
-- after it has already initialised the presenter and created a
swapchain, so the failure surfaces late and looks unrelated to config.

The existing call carried the comment 'Load config FIRST so log cvars
have final values', which is what it achieved for the log cvars further
down, but it sat below every path cvar read.

Resolve the default config path up front. It is derived purely from the
executable folder and the app name, so it does not depend on any cvar
and the ordering cannot become circular. OnConfigurePaths() may still
redirect config_path, so a second load is kept for that case only,
guarded on the path having actually changed to avoid applying the same
file twice.
@Azkali
Azkali force-pushed the fix/config-load-before-path-cvars branch from 0793608 to c82f6cf Compare July 22, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: config file is loaded after the path cvars it can set are read, so game_data_root in the TOML is ignored

2 participants