{"record":{"id":"fcd479d5522562d8","repo":"iflytek/astron-agent","slug":"can-not-find-relative-path-main","errorCode":null,"errorMessage":"can not find {relative_path}","messagePattern":"can not find (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"core/plugin/link/main.py","lineNumber":85,"sourceCode":"                    print(f\"ENV  ✅ {key.strip()}={os.environ.get(key.strip())}\")\n                else:\n                    print(f\"CFG  ✅ {key.strip()}={value.strip()}\")\n\n            else:\n                print(f\"  ⚠️  Line {line_num} format error: {line}\")\n\n\ndef start_service() -> None:\n    \"\"\"Start FastAPI service\"\"\"\n    print(\"\\n🚀 Starting Link service...\")\n\n    try:\n        # Start FastAPI application\n        relative_path = (Path(__file__).resolve().parent).relative_to(\n            Path.cwd()\n        ) / \"app/start_server.py\"\n        if not relative_path.exists():\n            raise FileNotFoundError(f\"can not find {relative_path}\")\n        subprocess.run([sys.executable, relative_path], check=True)\n    except subprocess.CalledProcessError as e:\n        print(f\"❌ Service startup failed: {e}\")\n        sys.exit(1)\n    except KeyboardInterrupt:\n        print(\"\\n🛑 Service stopped\")\n        sys.exit(0)\n\n\ndef main() -> None:\n    \"\"\"Main function\"\"\"\n    print(\"🌟 Link Development Environment Launcher\")\n    print(\"=\" * 50)\n\n    # Set up Python path\n    setup_python_path()\n\n    # Load environment configuration","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/plugin/link/main.py#L67-L103","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nrelative_path = (Path(__file__).resolve().parent).relative_to(Path.cwd()) / \"app/start_server.py\"\n// after\nscript = Path(__file__).resolve().parent / \"app/start_server.py\"\nif not script.exists():\n    raise FileNotFoundError(f\"can not find {script}\")\nsubprocess.run([sys.executable, script], check=True)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nscript = Path(\"core/plugin/link/app/start_server.py\")\nif not script.exists():\n    raise SystemExit(f\"start_server.py not found at {script.resolve()}; run from repo root\")","typeGuard":null,"tryCatchPattern":"try:\n    start_service()\nexcept FileNotFoundError as e:\n    print(f\"Run from repository root: {e}\")\n    sys.exit(2)","preventionTips":["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"],"tags":["python","startup","file-not-found","working-directory"],"backgroundTag":"file-not-found","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}