{"record":{"id":"9d3e7d8520df5c3f","repo":"xpzouying/xiaohongshu-mcp","slug":"app-v-s","errorCode":null,"errorMessage":"拷贝 .app: %v: %s","messagePattern":"拷贝 \\.app: (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"browser/browser_download.go","lineNumber":327,"sourceCode":"\tif out, err := exec.Command(\"hdiutil\", \"attach\", archivePath, \"-nobrowse\", \"-mountpoint\", mountPoint).CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"hdiutil attach: %v: %s\", err, out)\n\t}\n\tdefer exec.Command(\"hdiutil\", \"detach\", mountPoint, \"-quiet\").Run()\n\n\tvar appPath string\n\tentries, _ := os.ReadDir(mountPoint)\n\tfor _, e := range entries {\n\t\tif strings.HasSuffix(e.Name(), \".app\") {\n\t\t\tappPath = filepath.Join(mountPoint, e.Name())\n\t\t\tbreak\n\t\t}\n\t}\n\tif appPath == \"\" {\n\t\treturn fmt.Errorf(\"dmg 内未找到 .app\")\n\t}\n\tdstApp := filepath.Join(destDir, filepath.Base(appPath))\n\tif out, err := exec.Command(\"cp\", \"-R\", appPath, dstApp).CombinedOutput(); err != nil {\n\t\treturn fmt.Errorf(\"拷贝 .app: %v: %s\", err, out)\n\t}\n\t_ = exec.Command(\"xattr\", \"-dr\", \"com.apple.quarantine\", dstApp).Run()\n\treturn nil\n}\n","sourceCodeStart":309,"sourceCodeEnd":332,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/browser/browser_download.go#L309-L332","documentation":"extractDmg 在 macOS 上把挂载镜像里找到的 .app 拷贝到目标目录时 cp 命令失败：磁盘空间不足、权限不足或目标目录不可写，附带了 cp 的输出便于定位。","triggerScenarios":"extractDmg found appPath and runs exec.Command(\"cp\", \"-R\", appPath, dstApp).CombinedOutput(); cp exits non-zero (destination exists and is not writable, source vanished after unmount, disk full, permission denied).","commonSituations":"A previous partial install left a conflicting dstApp directory; the mounted volume detached before the copy finished; the destination directory is read-only or owned by another user; sandboxed/CI environments restrict spawning cp; disk space exhausted mid-copy.","solutions":["Remove the stale destination bundle at filepath.Join(destDir, appName) and re-run EnsureBrowser","Check free disk space on the destination volume","Verify destDir permissions (must be writable by the current user)","Run `cp -R <mounted>.app <dest>` manually to see the raw failure and confirm the volume is still mounted","Check `hdiutil info` for early detachments; ensure the deferred detach doesn't race the copy"],"exampleFix":"// before\nif out, err := exec.Command(\"cp\", \"-R\", appPath, dstApp).CombinedOutput(); err != nil {\n\treturn fmt.Errorf(\"拷贝 .app: %v: %s\", err, out)\n}\n// after — clear stale destination and retry once\n_ = os.RemoveAll(dstApp)\nif out, err := exec.Command(\"cp\", \"-R\", appPath, dstApp).CombinedOutput(); err != nil {\n\treturn fmt.Errorf(\"拷贝 .app: %v: %s\", err, out)\n}","handlingStrategy":"validation","validationCode":"dstApp := filepath.Join(destDir, appName)\nif _, err := os.Stat(dstApp); err == nil {\n\t// 目标已存在，先清理避免 cp 冲突\n\tos.RemoveAll(dstApp)\n}\nif err := unix.Access(destDir, unix.W_OK); err != nil {\n\t// 目标目录不可写\n}","typeGuard":null,"tryCatchPattern":"if err := EnsureBrowser(ctx); err != nil {\n\tif strings.Contains(err.Error(), \"拷贝 .app\") {\n\t\t// 清理目标目录并重试\n\t\tos.RemoveAll(destDir)\n\t\treturn EnsureBrowser(ctx)\n\t}\n\treturn err\n}","preventionTips":["Ensure the destination directory is empty and writable before install","Check available disk space before copying large app bundles","Run under a user with permission on destDir","Avoid concurrent EnsureBrowser runs racing on the same destination"],"tags":["macos","dmg","copy","permissions","external-command"],"backgroundTag":"file-copy-failed","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}