From ab98f1f31ee2595730729addee64c719511235af Mon Sep 17 00:00:00 2001 From: Tushar Date: Fri, 10 Apr 2026 15:49:43 +0530 Subject: [PATCH 1/3] fix(config): prefer ~/.forge when it exists, fall back to ~/forge --- crates/forge_config/src/reader.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/forge_config/src/reader.rs b/crates/forge_config/src/reader.rs index aa77518347..8b9642d1f3 100644 --- a/crates/forge_config/src/reader.rs +++ b/crates/forge_config/src/reader.rs @@ -67,18 +67,17 @@ impl ConfigReader { let home = dirs::home_dir().unwrap_or(PathBuf::from(".")); let path = home.join(".forge"); - let legacy_path = home.join("forge"); // Prefer the legacy ~/forge path while it still exists so that an // empty ~/.forge directory (e.g. created by `mkdir -p` in the shell // plugin) does not cause the base path to flip before migration. - if legacy_path.exists() { - tracing::info!("Using legacy path"); - return legacy_path; + if path.exists() { + tracing::info!("Using new path"); + return path; } - tracing::info!("Using new path"); - path + tracing::info!("Using legacy path"); + home.join("forge") } /// Adds the provided TOML string as a config source without touching the From 3bbc0ce4e88670b9624f0f2575f6e3ce09f325de Mon Sep 17 00:00:00 2001 From: Tushar Date: Fri, 10 Apr 2026 15:50:56 +0530 Subject: [PATCH 2/3] docs(config): clarify base_path resolution order in comments --- crates/forge_config/src/reader.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/forge_config/src/reader.rs b/crates/forge_config/src/reader.rs index 8b9642d1f3..b4fef5df2d 100644 --- a/crates/forge_config/src/reader.rs +++ b/crates/forge_config/src/reader.rs @@ -51,15 +51,12 @@ impl ConfigReader { /// Returns the base directory for all Forge config files. /// - /// If the `FORGE_CONFIG` environment variable is set, its value is used - /// directly as the base path. Otherwise defaults to `~/.forge`. - /// Falls back to the legacy `~/forge` path if it exists, even if `~/.forge` - /// also exists. This prevents tools that eagerly create `~/.forge` (such as - /// the shell plugin's config-edit action) from silently switching the - /// active base path while the user's credentials and config still live - /// in `~/forge`. Once the user runs `forge config migrate` the - /// `~/forge` directory is removed, so this fallback naturally stops - /// applying. + /// Resolution order: + /// 1. `FORGE_CONFIG` environment variable, if set. + /// 2. `~/.forge`, if that directory exists. + /// 3. `~/forge` (legacy path) as a fallback, so users who have not yet + /// run `forge config migrate` continue to read from their existing + /// directory without disruption. pub fn base_path() -> PathBuf { if let Ok(path) = std::env::var("FORGE_CONFIG") { return PathBuf::from(path); @@ -68,9 +65,8 @@ impl ConfigReader { let home = dirs::home_dir().unwrap_or(PathBuf::from(".")); let path = home.join(".forge"); - // Prefer the legacy ~/forge path while it still exists so that an - // empty ~/.forge directory (e.g. created by `mkdir -p` in the shell - // plugin) does not cause the base path to flip before migration. + // Prefer ~/.forge when it exists; fall back to ~/forge for users who + // have not yet migrated. if path.exists() { tracing::info!("Using new path"); return path; From 96def49dafd2572802e4f48df96a58e6b8442266 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 10 Apr 2026 10:25:27 +0000 Subject: [PATCH 3/3] [autofix.ci] apply automated fixes --- crates/forge_config/src/reader.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/forge_config/src/reader.rs b/crates/forge_config/src/reader.rs index b4fef5df2d..e16feed368 100644 --- a/crates/forge_config/src/reader.rs +++ b/crates/forge_config/src/reader.rs @@ -54,9 +54,9 @@ impl ConfigReader { /// Resolution order: /// 1. `FORGE_CONFIG` environment variable, if set. /// 2. `~/.forge`, if that directory exists. - /// 3. `~/forge` (legacy path) as a fallback, so users who have not yet - /// run `forge config migrate` continue to read from their existing - /// directory without disruption. + /// 3. `~/forge` (legacy path) as a fallback, so users who have not yet run + /// `forge config migrate` continue to read from their existing directory + /// without disruption. pub fn base_path() -> PathBuf { if let Ok(path) = std::env::var("FORGE_CONFIG") { return PathBuf::from(path);