fix: load .env from current working directory, not source file directory
The previous load_dotenv() searched for .env starting from the calling file's directory (haiku/rag/cli.py), which fails when users run haiku-rag from a different directory containing their .env file. Changes: - Move load_dotenv() before config imports (config reads env vars at import time) - Use find_dotenv(usecwd=True) to search from current working directory
This commit is contained in:
parent
6201303df3
commit
910ebbab22
1 changed files with 5 additions and 4 deletions
|
|
@ -8,7 +8,11 @@ from pathlib import Path
|
|||
from typing import Any
|
||||
|
||||
import typer
|
||||
from dotenv import load_dotenv
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
|
||||
# Load environment variables from .env file for API keys and service URLs.
|
||||
# Env loading needs to be before config import; usecwd=True searches from cwd, not this .py file's location
|
||||
load_dotenv(find_dotenv(usecwd=True))
|
||||
|
||||
from haiku.rag.app import HaikuRAGApp
|
||||
from haiku.rag.config import (
|
||||
|
|
@ -22,9 +26,6 @@ from haiku.rag.logging import configure_cli_logging
|
|||
from haiku.rag.store.exceptions import MigrationRequiredError
|
||||
from haiku.rag.utils import is_up_to_date
|
||||
|
||||
# Load environment variables from .env file for API keys and service URLs
|
||||
load_dotenv()
|
||||
|
||||
_cli = typer.Typer(
|
||||
context_settings={"help_option_names": ["-h", "--help"]}, no_args_is_help=True
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue