From 68fafeaf8d9fea8e21dfabfa20e0b65d7365238e Mon Sep 17 00:00:00 2001 From: Creeperkatze <178587183+Creeperkatze@users.noreply.github.com> Date: Wed, 11 Feb 2026 19:59:43 +0100 Subject: [PATCH 1/2] Make THESEUS_CONFIG_DIR work in dev mode --- packages/app-lib/.env.local | 3 +++ packages/app-lib/src/state/dirs.rs | 10 +++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/app-lib/.env.local b/packages/app-lib/.env.local index 171b37b9e6..4ef869e277 100644 --- a/packages/app-lib/.env.local +++ b/packages/app-lib/.env.local @@ -4,6 +4,9 @@ MODRINTH_API_URL_V3=http://127.0.0.1:8000/v3/ MODRINTH_SOCKET_URL=ws://127.0.0.1:8000/ MODRINTH_LAUNCHER_META_URL=https://launcher-meta.modrinth.com/ +# Theseus config directory for development +# THESEUS_CONFIG_DIR= + # SQLite database file used by sqlx for type checking. Uncomment this to a valid path # in your system and run `cargo sqlx database setup` to generate an empty database that # can be used for developing the app DB schema diff --git a/packages/app-lib/src/state/dirs.rs b/packages/app-lib/src/state/dirs.rs index b098dbcac0..c3b1a2e0b3 100644 --- a/packages/app-lib/src/state/dirs.rs +++ b/packages/app-lib/src/state/dirs.rs @@ -33,7 +33,9 @@ impl DirectoryInfo { // Get the settings directory // init() is not needed for this function pub fn initial_settings_dir_path(app_identifier: &str) -> Option { - Self::env_path("THESEUS_CONFIG_DIR") + // Use option_env! to read compile-time env var set by build.rs from .env file + option_env!("THESEUS_CONFIG_DIR") + .and_then(|p| if p.is_empty() { None } else { Some(PathBuf::from(p)) }) .or_else(|| Some(dirs::data_dir()?.join(app_identifier))) } @@ -184,12 +186,6 @@ impl DirectoryInfo { self.config_dir.join(CACHES_FOLDER_NAME) } - /// Get path from environment variable - #[inline] - fn env_path(name: &str) -> Option { - std::env::var_os(name).map(PathBuf::from) - } - #[tracing::instrument(skip(settings, exec, io_semaphore))] pub async fn move_launcher_directory<'a, E>( settings: &mut Settings, From e8f72078ce0c7c173f4f16d27d2d79a06bf349ad Mon Sep 17 00:00:00 2001 From: Creeperkatze <178587183+Creeperkatze@users.noreply.github.com> Date: Wed, 11 Feb 2026 20:20:06 +0100 Subject: [PATCH 2/2] Run fix --- packages/app-lib/src/state/dirs.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/app-lib/src/state/dirs.rs b/packages/app-lib/src/state/dirs.rs index c3b1a2e0b3..7154db6d54 100644 --- a/packages/app-lib/src/state/dirs.rs +++ b/packages/app-lib/src/state/dirs.rs @@ -35,7 +35,13 @@ impl DirectoryInfo { pub fn initial_settings_dir_path(app_identifier: &str) -> Option { // Use option_env! to read compile-time env var set by build.rs from .env file option_env!("THESEUS_CONFIG_DIR") - .and_then(|p| if p.is_empty() { None } else { Some(PathBuf::from(p)) }) + .and_then(|p| { + if p.is_empty() { + None + } else { + Some(PathBuf::from(p)) + } + }) .or_else(|| Some(dirs::data_dir()?.join(app_identifier))) }