fix(cli): load .env from user's CWD when run as console script

load_dotenv() with no arguments walks up from site-packages instead
of the user's CWD, so the installed tradingagents console script
silently misses the project's .env. Pass find_dotenv(usecwd=True)
so the search starts from CWD; same treatment for .env.enterprise.

#726 #755 #612 #747 #743 #753 #729 #728 #751
This commit is contained in:
Yijia-Xiao
2026-05-10 09:49:07 +00:00
parent 7e9e7b83c7
commit db7e0a67e2
2 changed files with 8 additions and 7 deletions

View File

@@ -4,11 +4,13 @@ import typer
from pathlib import Path from pathlib import Path
from functools import wraps from functools import wraps
from rich.console import Console from rich.console import Console
from dotenv import load_dotenv from dotenv import find_dotenv, load_dotenv
# Load environment variables # Search starts from the user's CWD so the installed `tradingagents`
load_dotenv() # console script picks up the project's .env instead of walking up from
load_dotenv(".env.enterprise", override=False) # site-packages.
load_dotenv(find_dotenv(usecwd=True))
load_dotenv(find_dotenv(".env.enterprise", usecwd=True), override=False)
from rich.panel import Panel from rich.panel import Panel
from rich.spinner import Spinner from rich.spinner import Spinner
from rich.live import Live from rich.live import Live

View File

@@ -1,10 +1,9 @@
from tradingagents.graph.trading_graph import TradingAgentsGraph from tradingagents.graph.trading_graph import TradingAgentsGraph
from tradingagents.default_config import DEFAULT_CONFIG from tradingagents.default_config import DEFAULT_CONFIG
from dotenv import load_dotenv from dotenv import find_dotenv, load_dotenv
# Load environment variables from .env file load_dotenv(find_dotenv(usecwd=True))
load_dotenv()
# Create a custom config # Create a custom config
config = DEFAULT_CONFIG.copy() config = DEFAULT_CONFIG.copy()