{"record":{"id":"3243039e380d17db","repo":"flipped-aurora/gin-vue-admin","slug":"w-324303","errorCode":null,"errorMessage":"创建编译目录失败: %w","messagePattern":"创建编译目录失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/plugin/ai/service/sys_cli_build.go","lineNumber":94,"sourceCode":"\treturn s.compileCliBinary(cli, manifestBytes, goos, goarch)\n}\n\n// compileCliBinary 把 manifest 内嵌进 gva 源码副本并交叉编译，返回二进制文件名与内容。\nfunc (s *cliService) compileCliBinary(cli autoModel.SysCli, manifestBytes []byte, goos, goarch string) (string, []byte, error) {\n\tif _, err := exec.LookPath(\"go\"); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"服务器未安装 Go 工具链，无法编译: %w\", err)\n\t}\n\tabsBuildRoot, err := filepath.Abs(cliBuildDir)\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"解析编译目录失败: %w\", err)\n\t}\n\tif err := os.MkdirAll(absBuildRoot, 0o755); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"创建编译根目录失败: %w\", err)\n\t}\n\n\tbuildDir, err := os.MkdirTemp(absBuildRoot, \"cli-\")\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"创建编译目录失败: %w\", err)\n\t}\n\tdefer os.RemoveAll(buildDir)\n\n\tif err := copyCliSources(cliSourceDir, buildDir); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tif err := writeEmbeddedManifest(buildDir, manifestBytes); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tbinaryName := sanitizeSingleSegmentSlug(cli.Command)\n\tif binaryName == \"\" {\n\t\tbinaryName = \"cli\"\n\t}\n\tbinaryName += cliBinaryExt(goos)\n\tbinaryPath := filepath.Join(buildDir, binaryName)\n\n\tif err := runGoBuild(buildDir, binaryPath, goos, goarch); err != nil {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/plugin/ai/service/sys_cli_build.go#L76-L112","documentation":"After creating the build root, compileCliBinary allocates a per-build temp directory with os.MkdirTemp(absBuildRoot, \"cli-\"). Failure here (wrapped in this error) means a new temp subdir could not be created even though the root exists — typically a race, permission change, or filesystem full condition.","triggerScenarios":"Disk full or inode exhaustion on the partition holding absBuildRoot; permissions changed on the build root between MkdirAll and MkdirTemp; concurrent cleanup scripts deleting the root mid-build; quota limits on the volume.","commonSituations":"Long-running servers whose build dir filled up with stale cli-* temp dirs; monitoring jobs or cron cleaning the build root while a build is in flight; small tmpfs volume allocated for the build directory.","solutions":["Check disk space and inodes (df -h / df -i) on the volume holding the build dir and free space","Clean up stale cli-* directories left by crashed builds","Ensure no external cleanup job deletes the build root while builds run; scope cleanup to old dirs only","Grant the server user write permission on the build root again if it changed","If a previous build crashed, note MkdirTemp dirs are removed via defer os.RemoveAll only on clean returns — sweep orphans periodically"],"exampleFix":"# find and remove orphaned build dirs older than a day\nfind /var/lib/gva/cli-build -maxdepth 1 -name 'cli-*' -mtime +1 -exec rm -rf {} +","handlingStrategy":"retry","validationCode":"if st, err := os.Stat(cliBuildDir); err != nil || !st.IsDir() {\n    return errors.New(\"build root missing or not a directory\")\n}","typeGuard":null,"tryCatchPattern":"bin, content, err := svc.BuildCliBinary(cli, manifest, goos, goarch)\nif err != nil {\n    if strings.Contains(err.Error(), \"创建编译目录失败\") && isTransient(err) {\n        time.Sleep(500 * time.Millisecond)\n        return svc.BuildCliBinary(cli, manifest, goos, goarch) // one retry\n    }\n    return err\n}","preventionTips":["Monitor disk space/inodes on the build volume","Periodically sweep orphaned cli-* temp dirs from crashed builds","Scope cleanup jobs to old directories only, never delete the root mid-build"],"tags":["go","filesystem","temp-directory","disk-space"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}