{"record":{"id":"6d423c1fc6d4b007","repo":"FoundationAgents/MetaGPT","slug":"dist-dir-must-be-an-absolute-path","errorCode":null,"errorMessage":"dist_dir must be an absolute path.","messagePattern":"dist_dir must be an absolute path\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/roles/di/engineer2.py","lineNumber":153,"sourceCode":"            await reporter.async_report({\"type\": \"code\", \"filename\": Path(path).name, \"src_path\": path}, \"meta\")\n            rsp = await self.llm.aask(context, system_msgs=[WRITE_CODE_SYSTEM_PROMPT])\n            code = CodeParser.parse_code(text=rsp)\n            await awrite(path, code)\n            await reporter.async_report(path, \"path\")\n\n        # TODO: Consider adding line no to be ready for editing.\n        return f\"The file {path} has been successfully created, with content:\\n{code}\"\n\n    async def _deploy_to_public(self, dist_dir):\n        \"\"\"fix the dist_dir path to absolute path before deploying\n        Args:\n            dist_dir (str): The dist directory of the web project after run build. This must be an absolute path.\n        \"\"\"\n        # Try to fix the path with the editor's working directory.\n        if not Path(dist_dir).is_absolute():\n            default_dir = self.editor._try_fix_path(dist_dir)\n            if not default_dir.exists():\n                raise ValueError(\"dist_dir must be an absolute path.\")\n            dist_dir = default_dir\n        return await self.deployer.deploy_to_public(dist_dir)\n\n    async def _eval_terminal_run(self, cmd):\n        \"\"\"change command pull/push/commit to end.\"\"\"\n        if any([cmd_key_word in cmd for cmd_key_word in [\"pull\", \"push\", \"commit\"]]):\n            # The Engineer2 attempts to submit the repository after fixing the bug, thereby reaching the end of the fixing process.\n            logger.info(\"Engineer2 use cmd:{cmd}\\nCurrent test case is finished.\")\n            # Set self.rc.todo to None to stop the engineer.\n            self._set_state(-1)\n        else:\n            command_output = await self.terminal.run_command(cmd)\n        return command_output\n\n    async def _end(self):\n        if not self.planner.plan.is_plan_finished():\n            self.planner.plan.finish_all_tasks()\n        return await super()._end()","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/roles/di/engineer2.py#L135-L171","documentation":"Engineer2._deploy_to_public requires an absolute dist_dir (the built web project output). If a relative path is given, it attempts to fix it via editor._try_fix_path; when the fixed path still does not exist on disk, this ValueError is raised. It signals the build output directory could not be located.","triggerScenarios":"The deploy action receives a relative dist_dir (e.g. \"dist\" or \"build\") from the LLM-driven workflow, and the editor's working directory does not contain that folder — either the build never ran or it output elsewhere.","commonSituations":"The web build step failed or was skipped so dist/ was never created; the agent passed a path relative to a different cwd; project scaffold put build output in a nested folder.","solutions":["Run the web build (npm run build) first and confirm the dist folder exists on disk","Pass an absolute path to _deploy_to_public / the deploy action","Check editor._try_fix_path's base working directory matches where the build output lives"],"exampleFix":"// before\nawait self._deploy_to_public(\"dist\")  # relative, may not resolve -> ValueError\n\n// after\nawait self._deploy_to_public(str(project_root / \"dist\"))  # absolute path","handlingStrategy":"validation","validationCode":"from pathlib import Path\ndist = Path(dist_dir)\nif not dist.is_absolute():\n    dist = (project_root / dist).resolve()\nif not dist.exists():\n    raise FileNotFoundError(f\"build output not found at {dist}; run the web build first\")","typeGuard":null,"tryCatchPattern":"try:\n    await self._deploy_to_public(dist_dir)\nexcept ValueError as e:\n    if \"absolute path\" in str(e):\n        raise RuntimeError(f\"build output missing for {dist_dir}; run npm run build first\") from e\n    raise","preventionTips":["Run and verify the web build step before the deploy action","Always pass absolute paths to deploy steps","Assert the dist directory exists in a pre-deploy check"],"tags":["deployment","path","engineer-agent","web"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}