xpzouying/xiaohongshu-mcp · error
dmg 内未找到 .app
Error message
dmg 内未找到 .app
What it means
After mounting the .dmg, extractDmg lists the mountpoint's top-level entries looking for a directory ending in .app. This error is thrown when no such entry exists at the root of the mounted volume, so there is nothing to copy to the destination.
Source
Thrown at browser/browser_download.go:323
return err
}
defer os.RemoveAll(mountPoint)
if out, err := exec.Command("hdiutil", "attach", archivePath, "-nobrowse", "-mountpoint", mountPoint).CombinedOutput(); err != nil {
return fmt.Errorf("hdiutil attach: %v: %s", err, out)
}
defer exec.Command("hdiutil", "detach", mountPoint, "-quiet").Run()
var appPath string
entries, _ := os.ReadDir(mountPoint)
for _, e := range entries {
if strings.HasSuffix(e.Name(), ".app") {
appPath = filepath.Join(mountPoint, e.Name())
break
}
}
if appPath == "" {
return fmt.Errorf("dmg 内未找到 .app")
}
dstApp := filepath.Join(destDir, filepath.Base(appPath))
if out, err := exec.Command("cp", "-R", appPath, dstApp).CombinedOutput(); err != nil {
return fmt.Errorf("拷贝 .app: %v: %s", err, out)
}
_ = exec.Command("xattr", "-dr", "com.apple.quarantine", dstApp).Run()
return nil
}
View on GitHub (pinned to 332d196854)
Solutions
- Mount the .dmg manually with hdiutil attach and inspect its contents to confirm the .app location
- Extend extractDmg to search nested directories (filepath.Walk) instead of only the volume root
- Re-download the correct .dmg for your OS/arch if a wrong product image was fetched
- Check for leftover mounts (hdiutil info) that could shadow the intended mountpoint
- Update the library if upstream restructured the disk image
Example fix
// before
entries, _ := os.ReadDir(mountPoint)
for _, e := range entries {
if strings.HasSuffix(e.Name(), ".app") {
appPath = filepath.Join(mountPoint, e.Name())
break
}
}
// after — recursive search
filepath.Walk(mountPoint, func(p string, info os.FileInfo, err error) error {
if err == nil && strings.HasSuffix(p, ".app") && appPath == "" {
appPath = p
}
return nil
}) Defensive patterns
Strategy: validation
Validate before calling
// 挂载后先检查卷根目录是否包含 .app
entries, _ := os.ReadDir(mountPoint)
hasApp := false
for _, e := range entries {
if strings.HasSuffix(e.Name(), ".app") { hasApp = true }
}
if !hasApp { return errors.New("dmg 布局不含顶层 .app") } Try / catch
if err := EnsureBrowser(ctx); err != nil {
if strings.Contains(err.Error(), "dmg 内未找到 .app") {
// 手动挂载检查布局,必要时改用 zip/其他分发格式
return manualInstall()
}
return err
} Prevention
- Inspect the .dmg layout of the target version before automating installs
- Clean up leftover mounts (hdiutil detach) to avoid attaching the wrong volume
- Pin to a version whose disk-image layout is known to work
- Prefer zip distribution on macOS when available to avoid dmg handling entirely
When it happens
Trigger: extractDmg mounts the image successfully, os.ReadDir(mountPoint) returns entries, but none has strings.HasSuffix(e.Name(), ".app") — the volume root contains only other files/folders (docs, packages, symlinks).
Common situations: Upstream changed the .dmg layout (app nested in a subfolder); the mounted volume is an installer .pkg-style image rather than a drag-to-Applications image; a stale mount or wrong volume was attached (mountpoint collision); the .dmg is for a different product/version.
Related errors
AI-assisted analysis of xpzouying/xiaohongshu-mcp@332d196854 (2026-09-05).
Data as JSON: /api/errors/0f433f10380fe25b.
Report an issue: GitHub.