-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Do you need to file an issue?
- I have searched the existing issues and this bug is not already filed.
- I believe this is a legitimate bug, not just a question or feature request.
Describe the bug
Incorrect .env file detection path in #1195 :
The check_env_file() function in utils_api.py incorrectly checks for the .env file in Working Directory instead of the API directory
This creates following issues:
Working directory constraint that requires users to start the server from a specific location
Current Behavior
- .env detection:
def check_env_file():
"""
Check if .env file exists and handle user confirmation if needed.
Returns True if should continue, False if should exit.
"""
if not os.path.exists(".env"):
warning_msg = (
"Warning: .env file not found. Some features may not work properly."
)
ASCIIColors.yellow(warning_msg)
# Check if running in interactive terminal
if sys.stdin.isatty():
response = input("Do you want to continue? (yes/no): ")
if response.lower() != "yes":
ASCIIColors.red("Server startup cancelled")
return False
return TrueSuggested Solutions
- Update environment file detection (just a example):
def check_env_file():
"""
Check if .env file exists and handle user confirmation if needed.
Returns True if should continue, False if should exit.
"""
# Get the absolute path of the current script's directory
current_dir = os.path.dirname(os.path.abspath(__file__))
env_path = os.path.join(current_dir, '.env')
if not os.path.exists(env_path):
# Add debug information
warning_msg = (
f"Warning: .env file not found at {env_path}. "
"Some features may not work properly."
)
ASCIIColors.yellow(warning_msg)
# Check if running in an interactive terminal
if sys.stdin.isatty():
response = input("Do you want to continue? (yes/no): ")
if response.lower() != "yes":
ASCIIColors.red("Server startup cancelled")
return False
else:
ASCIIColors.green(f"Found .env file at: {env_path}")
return TrueSteps to reproduce
No response
Expected Behavior
- The server should be able to locate the .env file regardless of the working directory
- Users should be able to start the server from any location
LightRAG Config Used
Paste your config here
Logs and screenshots
No response
Additional Information
- LightRAG Version:
- Operating System:
- Python Version:
- Related Issues:
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working