| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| // Without FORGE_CONFIG set the path must be either ".forge" (new) or | ||
| // "forge" (legacy fallback when ~/forge exists on this machine). | ||
| let name = actual.file_name().unwrap(); | ||
| assert!( | ||
| name == ".forge" || name == "forge", | ||
| "Expected base_path to end with '.forge' or 'forge', got: {:?}", | ||
| name | ||
| ); |
There was a problem hiding this comment.
Test is now non-deterministic and depends on the host filesystem state. If ~/forge exists on the CI/CD runner or developer's machine, the test validates different behavior than if it doesn't exist. This makes test results non-reproducible and can hide regressions.
Impact: Different environments will test different code paths, reducing test reliability.
Fix: Use filesystem isolation for deterministic testing:
#[test]
fn test_base_path_prefers_legacy_when_it_exists() {
let temp = TempDir::new().unwrap();
env::set_var("HOME", temp.path());
fs::create_dir(temp.path().join("forge")).unwrap();
let actual = ConfigReader::base_path();
assert_eq!(actual.file_name().unwrap(), "forge");
}Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fix ProviderNotAvailable errors caused by base_path() silently switching from ~/forge to ~/.forge when an empty ~/.forge directory was created as a side effect of the shell plugin's config-edit action.
Context
After adding the forge config migrate command (which teaches users to move from ~/forge to ~/.forge), the shell plugin's _forge_action_config_edit function was updated to call forge config path dynamically and then run mkdir -p <config_dir> to ensure the config directory exists.
The problem: forge config path returns ~/.forge/.forge.toml as the new default (since 26badbaac changed base_path() to prefer ~/.forge). So for users who still have their data in ~/forge, the shell plugin would eagerly create an empty ~/.forge directory. This caused base_path() to flip:
With base_path() now returning ~/.forge, credentials_path() pointed to ~/.forge/.credentials.json — a file that doesn't exist because all credentials are in ~/forge/.credentials.json. read_credentials() returned an empty list, every provider appeared unconfigured, and every provider lookup raised ProviderNotAvailable.
Changes
Testing
Reproduce and verify the fix: