hashicorp/nomad · error
unable to get CWD from filesystem: %s
Error message
unable to get CWD from filesystem: %s
What it means
The storage fingerprinter needs a directory to measure disk space for. When cfg.AllocDir is empty it falls back to os.Getwd(); if that fails (the working directory no longer exists or is inaccessible), it returns this error.
Source
Thrown at client/fingerprint/storage.go:38
StaticFingerprinter
logger log.Logger
}
func NewStorageFingerprint(logger log.Logger) Fingerprint {
fp := &StorageFingerprint{logger: logger.Named("storage")}
return fp
}
func (f *StorageFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
cfg := req.Config
// Guard against unset AllocDir
storageDir := cfg.AllocDir
if storageDir == "" {
var err error
storageDir, err = os.Getwd()
if err != nil {
return fmt.Errorf("unable to get CWD from filesystem: %s", err)
}
}
volume, total, err := f.diskInfo(storageDir)
if err != nil {
return fmt.Errorf("failed to determine disk space for %s: %v", storageDir, err)
}
if cfg.DiskTotalMB > 0 {
total = uint64(cfg.DiskTotalMB) * bytesPerMegabyte
}
resp.AddAttribute("unique.storage.volume", volume)
resp.AddAttribute("unique.storage.bytestotal", strconv.FormatUint(total, 10))
// set the disk size for the response
resp.NodeResources = &structs.NodeResources{
Disk: structs.NodeDiskResources{View on GitHub (pinned to 482b49bf1a)
Solutions
- Set AllocDir (the client data/alloc directory) explicitly in the client configuration.
- Start the client from an existing directory, or recreate the deleted CWD.
- Check filesystem permissions on the working directory.
- Ensure the client's systemd/service unit uses a valid WorkingDirectory.
Example fix
// before
# alloc dir unset; process CWD deleted
// after (client config hcl)
client {
alloc_dir = "/opt/nomad/data/alloc"
} Defensive patterns
Strategy: validation
Validate before calling
wd, err := os.Getwd()
if err != nil {
return fmt.Errorf("process CWD is invalid, set alloc_dir explicitly: %w", err)
} Try / catch
if err := fp.Fingerprint(req); err != nil {
if strings.Contains(err.Error(), "unable to get CWD from filesystem") {
log.Print("CWD unavailable; set alloc_dir in client config")
return nil
}
return err
} Prevention
- Always configure alloc_dir explicitly in the Nomad client config.
- Ensure the service unit's WorkingDirectory exists and is not removed at runtime.
- Avoid starting the client from temporary directories.
- Monitor for CWD deletion in long-running processes.
When it happens
Trigger: StorageFingerprint.Fingerprint with cfg.AllocDir == "" and os.Getwd() returning an error (typically ENOENT because the process's current working directory was deleted or unreadable).
Common situations: Nomad client started in a directory later removed; running the client in a container whose workdir was deleted; missing permissions on the CWD.
Related errors
- failed to determine disk space for %s: %v
- failed to determine absolute path for %s
- failed to determine mount point for %s
- failed to parse `df` output; expected at least 2 lines
- failed to parse `df` output; expected at least 4 columns
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/6d95f1aa88f12daf.
Report an issue: GitHub.