iflytek/astron-agent · error · FileNotFoundError
can not find
Error message
can not find {relative_path} What it means
FileNotFoundError raised by the link plugin's start_service() entrypoint: it computes the repo-relative path to app/start_server.py from the location of main.py and the current working directory, and raises when that file does not exist. It is a guard against launching the subprocess with a missing script.
Solutions
- Run the service from the repository root: cd to the repo root before executing main.py.
- Invoke the start script directly instead: python core/plugin/link/app/start_server.py.
- Fix start_service to build the absolute path from __file__ alone (no dependence on cwd): script = Path(__file__).resolve().parent / "app/start_server.py".
- Verify the file exists in your checkout/container image (may have been excluded by .dockerignore or copy step).
Example fix
// before
relative_path = (Path(__file__).resolve().parent).relative_to(Path.cwd()) / "app/start_server.py"
// after
script = Path(__file__).resolve().parent / "app/start_server.py"
if not script.exists():
raise FileNotFoundError(f"can not find {script}")
subprocess.run([sys.executable, script], check=True) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
script = Path("core/plugin/link/app/start_server.py")
if not script.exists():
raise SystemExit(f"start_server.py not found at {script.resolve()}; run from repo root") Try / catch
try:
start_service()
except FileNotFoundError as e:
print(f"Run from repository root: {e}")
sys.exit(2) Prevention
- Always run plugin entrypoints from the repo root
- Prefer __file__-relative absolute paths over cwd-relative paths
- Verify docker copies preserve the app/start_server.py layout
When it happens
Trigger: Running `python core/plugin/link/main.py` from a working directory that is not the repository root, so (Path(main.py).parent).relative_to(Path.cwd()) yields the wrong path or the computed start_server.py path does not exist.
Common situations: Developers invoke main.py from core/plugin/link/ or an arbitrary directory instead of the repo root; CI containers copy files without preserving the expected layout; renamed/moved start_server.py.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/fcd479d5522562d8.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/link/main.py:85
print(f"ENV ✅ {key.strip()}={os.environ.get(key.strip())}")
else:
print(f"CFG ✅ {key.strip()}={value.strip()}")
else:
print(f" ⚠️ Line {line_num} format error: {line}")
def start_service() -> None:
"""Start FastAPI service"""
print("\n🚀 Starting Link service...")
try:
# Start FastAPI application
relative_path = (Path(__file__).resolve().parent).relative_to(
Path.cwd()
) / "app/start_server.py"
if not relative_path.exists():
raise FileNotFoundError(f"can not find {relative_path}")
subprocess.run([sys.executable, relative_path], check=True)
except subprocess.CalledProcessError as e:
print(f"❌ Service startup failed: {e}")
sys.exit(1)
except KeyboardInterrupt:
print("\n🛑 Service stopped")
sys.exit(0)
def main() -> None:
"""Main function"""
print("🌟 Link Development Environment Launcher")
print("=" * 50)
# Set up Python path
setup_python_path()
# Load environment configurationView on GitHub (pinned to 5e758547a8)