From 9685bd533bbbf9e1701634056e97f65da92cfc88 Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Mon, 16 Feb 2026 17:21:35 +0200 Subject: [PATCH] Expand ~ in paths --- haiku_rag_slim/haiku/rag/config/loader.py | 2 +- tests/test_config.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/haiku_rag_slim/haiku/rag/config/loader.py b/haiku_rag_slim/haiku/rag/config/loader.py index 5c7a3074..4ed57646 100644 --- a/haiku_rag_slim/haiku/rag/config/loader.py +++ b/haiku_rag_slim/haiku/rag/config/loader.py @@ -18,7 +18,7 @@ def find_config_file(cli_path: Path | None = None) -> Path | None: if not cli_path: env_path = os.getenv("HAIKU_RAG_CONFIG_PATH") if env_path: - cli_path = Path(env_path) + cli_path = Path(env_path).expanduser() if cli_path: if cli_path.exists(): diff --git a/tests/test_config.py b/tests/test_config.py index 4932a6f3..db15b681 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -79,6 +79,19 @@ def test_find_config_file_env_var(tmp_path, monkeypatch): assert found == config_file +def test_find_config_file_env_var_tilde_expansion(tmp_path, monkeypatch): + """Test that ~ in HAIKU_RAG_CONFIG_PATH is expanded.""" + config_file = tmp_path / "from-env.yaml" + config_file.write_text("environment: production") + + # Point HOME to tmp_path so ~ expands there + monkeypatch.setenv("HOME", str(tmp_path)) + monkeypatch.setenv("HAIKU_RAG_CONFIG_PATH", "~/from-env.yaml") + + found = find_config_file() + assert found == config_file + + def test_find_config_file_not_found(tmp_path, monkeypatch): """Test returning None when no config found.""" monkeypatch.delenv("HAIKU_RAG_CONFIG_PATH", raising=False)