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..7154db6d54 100644 --- a/packages/app-lib/src/state/dirs.rs +++ b/packages/app-lib/src/state/dirs.rs @@ -33,7 +33,15 @@ 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 +192,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,