henrygd/beszel · error
failed to create temp directory: %w
Error message
failed to create temp directory: %w
What it means
On Windows the agent's LibreHardwareMonitor (LHM) helper requires copying its embedded executable to a temp directory; this error wraps an os.MkdirAll failure for %TEMP%\beszel. It indicates the temp directory could not be created — filesystem or permission problem — so no sensor data can be collected via LHM.
Source
Thrown at agent/sensors_windows.go:60
//go:embed all:lhm/bin/Release/net48
var lhmFs embed.FS
var (
beszelLhm *lhmProcess
beszelLhmOnce sync.Once
useLHM = os.Getenv("LHM") == "true"
)
var errNoSensors = errors.New("no sensors found (try running as admin with LHM=true)")
// newlhmProcess copies the embedded LHM executable to a temporary directory and starts it.
func newlhmProcess() (*lhmProcess, error) {
destDir := filepath.Join(os.TempDir(), "beszel")
execPath := filepath.Join(destDir, "beszel_lhm.exe")
if err := os.MkdirAll(destDir, 0755); err != nil {
return nil, fmt.Errorf("failed to create temp directory: %w", err)
}
// Only copy if executable doesn't exist
if _, err := os.Stat(execPath); os.IsNotExist(err) {
if err := copyEmbeddedDir(lhmFs, "lhm/bin/Release/net48", destDir); err != nil {
return nil, fmt.Errorf("failed to copy embedded directory: %w", err)
}
}
lhm := &lhmProcess{
execPath: execPath,
tempDir: destDir,
}
if err := lhm.startProcess(); err != nil {
return nil, fmt.Errorf("failed to start process: %w", err)
}
View on GitHub (pinned to b38fb7dafa)
Solutions
- Check TEMP/TMP env vars for the account running the agent and ensure the path exists and is writable.
- Free disk space if the volume holding %TEMP% is full.
- Run the agent service under an account with write permission to its temp directory, or set TEMP to a dedicated writable folder.
- Exclude the beszel temp dir from antivirus/temp-cleaner policies that delete it.
- Create the directory manually (mkdir %TEMP%\beszel) and re-run to confirm permissions.
Example fix
// before (service env) TEMP=C:\Windows\Temp # service account lacks write access // after set TEMP=C:\beszel\tmp (grant the service account Modify on it)
Defensive patterns
Strategy: try-catch
Validate before calling
// before starting LHM helper:
if err := os.MkdirAll(filepath.Join(os.TempDir(), "beszel"), 0755); err != nil {
return fmt.Errorf("temp dir unusable: %w", err)
} Try / catch
proc, err := newlhmProcess()
if err != nil {
if strings.Contains(err.Error(), "failed to create temp directory") {
slog.Warn("LHM unavailable: temp dir not writable", "err", err)
return nil // run without LHM sensor data
}
return err
} Prevention
- Ensure the agent's service account has write access to %TEMP%
- Set TEMP/TMP to a dedicated writable path for service deployments
- Exclude the temp dir from antivirus and temp-cleaner policies
- Monitor disk space on the volume hosting %TEMP%
When it happens
Trigger: newlhmProcess() builds destDir = os.TempDir()+"beszel" and calls os.MkdirAll(destDir, 0755); failure (ENOENT parent gone, EPERM, disk full, path redirected to a read-only location) wraps the OS error.
Common situations: TEMP/TMP env var pointing at a missing, read-only, or network path; enterprise policy restricting executable creation in temp; disk full; temp cleaner service removing the directory mid-run; agent running as a service account without write access to its temp dir.
Related errors
- no sensors found (try running as admin with LHM=true)
- failed to create smartctl directory: %w
- failed to write embedded smartctl: %w
- battery tag not returned
- battery capacity unknown
AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31).
Data as JSON: /api/errors/b792385e412fe523.
Report an issue: GitHub.