flipped-aurora/gin-vue-admin · error
解析编译目录失败: %w
Error message
解析编译目录失败: %w
What it means
compileCliBinary resolves the absolute path of cliBuildDir (the root directory used for CLI builds) via filepath.Abs. If Abs fails — which can happen when the process working directory has been removed or cannot be resolved — this wrapped error is returned and the build aborts. It is a defensive wrap around a normally-infallible call.
Source
Thrown at server/plugin/ai/service/sys_cli_build.go:86
if err != nil {
return "", nil, err
}
applyCliBuildBaseURL(&manifest, req.BaseURL)
manifestBytes, err := marshalSysCliManifest(manifest)
if err != nil {
return "", nil, err
}
return s.compileCliBinary(cli, manifestBytes, goos, goarch)
}
// compileCliBinary 把 manifest 内嵌进 gva 源码副本并交叉编译,返回二进制文件名与内容。
func (s *cliService) compileCliBinary(cli autoModel.SysCli, manifestBytes []byte, goos, goarch string) (string, []byte, error) {
if _, err := exec.LookPath("go"); err != nil {
return "", nil, fmt.Errorf("服务器未安装 Go 工具链,无法编译: %w", err)
}
absBuildRoot, err := filepath.Abs(cliBuildDir)
if err != nil {
return "", nil, fmt.Errorf("解析编译目录失败: %w", err)
}
if err := os.MkdirAll(absBuildRoot, 0o755); err != nil {
return "", nil, fmt.Errorf("创建编译根目录失败: %w", err)
}
buildDir, err := os.MkdirTemp(absBuildRoot, "cli-")
if err != nil {
return "", nil, fmt.Errorf("创建编译目录失败: %w", err)
}
defer os.RemoveAll(buildDir)
if err := copyCliSources(cliSourceDir, buildDir); err != nil {
return "", nil, err
}
if err := writeEmbeddedManifest(buildDir, manifestBytes); err != nil {
return "", nil, err
}
View on GitHub (pinned to 3136500ef3)
Solutions
- Restart the server process so its working directory is valid again
- Set the service's WorkingDirectory to a stable, always-existing path (e.g. /var/lib/gva)
- Make cliBuildDir an absolute path in configuration so filepath.Abs has nothing to resolve
- Ensure nothing external deletes the directory the process was started from
Example fix
# before (systemd) # no WorkingDirectory set # after [Service] WorkingDirectory=/var/lib/gva
Defensive patterns
Strategy: validation
Validate before calling
if wd, err := os.Getwd(); err != nil {
return fmt.Errorf("process working directory unusable: %w", err)
} Try / catch
bin, content, err := svc.BuildCliBinary(cli, manifest, goos, goarch)
if err != nil {
if strings.Contains(err.Error(), "解析编译目录失败") {
log.Println("build dir unresolvable; restart service or set absolute path")
}
return err
} Prevention
- Configure cliBuildDir as an absolute path
- Set a stable WorkingDirectory in systemd/container configs
- Avoid deleting the directory a running process was started from
When it happens
Trigger: The server process's current working directory was deleted while the process was running (common after container image rebuilds or tmp reaping), making filepath.Abs unable to resolve the relative cliBuildDir.
Common situations: Docker overlay filesystem cleanup removing the cwd; service started in a directory later deleted; working directory set to a removed tmp path in the systemd unit.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/161cbfb3e5459a81.
Report an issue: GitHub.