Skip to content

feat(config): allow configuration of the base_path#2864

Merged
tusharmath merged 5 commits intomainfrom
config-dir-path
Apr 7, 2026
Merged

feat(config): allow configuration of the base_path#2864
tusharmath merged 5 commits intomainfrom
config-dir-path

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 6, 2026

Fixes #2451 #1330 #2662

@tusharmath tusharmath changed the title config dir path feat(config): Allow configuration of the base_path Apr 6, 2026
@tusharmath tusharmath changed the title feat(config): Allow configuration of the base_path feat(config): allow configuration of the base_path Apr 6, 2026
Comment on lines +232 to +236
fn test_to_environment_falls_back_to_home_dir_when_env_var_absent() {
let actual = to_environment(PathBuf::from("/any/cwd"));
// Without FORGE_CONFIG the base_path must end with "forge"
assert_eq!(actual.base_path.file_name().unwrap(), "forge");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test assumes FORGE_CONFIG is not set but doesn't guarantee it. If FORGE_CONFIG is set in the test environment, the test will fail because to_environment() will return the env var value instead of a path ending in "forge".

Fix: Use EnvGuard to acquire the mutex and explicitly unset the variable:

#[test]
fn test_to_environment_falls_back_to_home_dir_when_env_var_absent() {
    let _guard = EnvGuard::set(&[]); // Ensures mutex is held
    unsafe { std::env::remove_var("FORGE_CONFIG") };
    let actual = to_environment(PathBuf::from("/any/cwd"));
    assert_eq!(actual.base_path.file_name().unwrap(), "forge");
}
Suggested change
fn test_to_environment_falls_back_to_home_dir_when_env_var_absent() {
let actual = to_environment(PathBuf::from("/any/cwd"));
// Without FORGE_CONFIG the base_path must end with "forge"
assert_eq!(actual.base_path.file_name().unwrap(), "forge");
}
#[test]
fn test_to_environment_falls_back_to_home_dir_when_env_var_absent() {
let _guard = EnvGuard::set(&[]); // Ensures mutex is held
unsafe { std::env::remove_var("FORGE_CONFIG") };
let actual = to_environment(PathBuf::from("/any/cwd"));
// Without FORGE_CONFIG the base_path must end with "forge"
assert_eq!(actual.base_path.file_name().unwrap(), "forge");
}

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Switch to ~/.config/forge from ~/forge (XDG compliant)

1 participant