flipped-aurora/gin-vue-admin · error
创建临时文件失败: %w
Error message
创建临时文件失败: %w
What it means
os.CreateTemp failed to create the temporary file used to stage the downloaded skill zip. This is a local filesystem error: os.CreateTemp fails when the temp directory (TMPDIR or /tmp) is unwritable, doesn't exist, or the system is out of inodes/space.
Source
Thrown at server/service/system/sys_skills.go:449
realDownloadURL := strings.TrimSpace(meta.Data.URL)
if realDownloadURL == "" {
return errors.New("下载结果缺少 url")
}
zipResp, err := http.Get(realDownloadURL)
if err != nil {
return fmt.Errorf("下载压缩包失败: %w", err)
}
defer zipResp.Body.Close()
if zipResp.StatusCode != http.StatusOK {
return fmt.Errorf("下载压缩包失败, HTTP状态码: %d", zipResp.StatusCode)
}
tmpFile, err := os.CreateTemp("", "gva-skill-*.zip")
if err != nil {
return fmt.Errorf("创建临时文件失败: %w", err)
}
tmpPath := tmpFile.Name()
defer os.Remove(tmpPath)
if _, err = io.Copy(tmpFile, zipResp.Body); err != nil {
tmpFile.Close()
return fmt.Errorf("保存技能包失败: %w", err)
}
tmpFile.Close()
if err = extractZipToDir(tmpPath, skillsDir); err != nil {
return fmt.Errorf("解压技能包失败: %w", err)
}
return nil
}
func extractZipToDir(zipPath, destDir string) error {View on GitHub (pinned to 3136500ef3)
Solutions
- Check TMPDIR and /tmp: ls -ld /tmp; touch /tmp/probe as the server user
- Free disk space / clean the filesystem if 'no space left on device'
- Mount a writable emptyDir/tmp volume in containerized deployments
- Verify the wrapped error: permission denied vs no space vs no such file or directory
Example fix
// pin a known-writable temp dir in containerized deployments
// before (relies on TMPDIR)
tmpFile, err := os.CreateTemp("", "gva-skill-*.zip")
// after
tmpFile, err := os.CreateTemp("/var/tmp/gva", "gva-skill-*.zip") // dir pre-created with correct perms Defensive patterns
Strategy: validation
Validate before calling
probe := filepath.Join(os.TempDir(), ".gva-probe")
if f, err := os.Create(probe); err != nil {
// temp dir unwritable/full — fix before attempting downloads
} else { f.Close(); os.Remove(probe) } Try / catch
if err := DownloadOnlineSkill(ctx, req); err != nil && strings.Contains(err.Error(), "创建临时文件失败") {
// check TMPDIR writability and disk space; surface a storage alert
} Prevention
- Ensure TMPDIR (or /tmp) exists, is writable by the service user, and has free space
- Mount a writable tmp volume in read-only container filesystems
- Alert on disk usage; clean stale temp files (gva-skill-*.zip leftovers)
- Pin an explicit temp directory with correct permissions in deployments
When it happens
Trigger: Calling DownloadOnlineSkill on a server whose TMPDIR points to a nonexistent/unwritable directory, /tmp is mounted read-only or full (no space left on device), or the process user lacks write permission to the temp dir.
Common situations: Containers with read-only root filesystems and no writable tmp mount; disk full after large log accumulation; hardened tmp permissions (sticky bit/ownership); TMPDIR misconfiguration in systemd units or k8s pods.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/b69e45ff91f79b73.
Report an issue: GitHub.