{"record":{"id":"6d95f1aa88f12daf","repo":"hashicorp/nomad","slug":"unable-to-get-cwd-from-filesystem-s","errorCode":null,"errorMessage":"unable to get CWD from filesystem: %s","messagePattern":"unable to get CWD from filesystem: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/fingerprint/storage.go","lineNumber":38,"sourceCode":"\tStaticFingerprinter\n\tlogger log.Logger\n}\n\nfunc NewStorageFingerprint(logger log.Logger) Fingerprint {\n\tfp := &StorageFingerprint{logger: logger.Named(\"storage\")}\n\treturn fp\n}\n\nfunc (f *StorageFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {\n\tcfg := req.Config\n\n\t// Guard against unset AllocDir\n\tstorageDir := cfg.AllocDir\n\tif storageDir == \"\" {\n\t\tvar err error\n\t\tstorageDir, err = os.Getwd()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to get CWD from filesystem: %s\", err)\n\t\t}\n\t}\n\n\tvolume, total, err := f.diskInfo(storageDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to determine disk space for %s: %v\", storageDir, err)\n\t}\n\n\tif cfg.DiskTotalMB > 0 {\n\t\ttotal = uint64(cfg.DiskTotalMB) * bytesPerMegabyte\n\t}\n\n\tresp.AddAttribute(\"unique.storage.volume\", volume)\n\tresp.AddAttribute(\"unique.storage.bytestotal\", strconv.FormatUint(total, 10))\n\n\t// set the disk size for the response\n\tresp.NodeResources = &structs.NodeResources{\n\t\tDisk: structs.NodeDiskResources{","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/fingerprint/storage.go#L20-L56","documentation":"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.","triggerScenarios":"StorageFingerprint.Fingerprint with cfg.AllocDir == \"\" and os.Getwd() returning an error (typically ENOENT because the process's current working directory was deleted or unreadable).","commonSituations":"Nomad client started in a directory later removed; running the client in a container whose workdir was deleted; missing permissions on the CWD.","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."],"exampleFix":"// before\n# alloc dir unset; process CWD deleted\n// after (client config hcl)\nclient {\n  alloc_dir = \"/opt/nomad/data/alloc\"\n}","handlingStrategy":"validation","validationCode":"wd, err := os.Getwd()\nif err != nil {\n\treturn fmt.Errorf(\"process CWD is invalid, set alloc_dir explicitly: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := fp.Fingerprint(req); err != nil {\n\tif strings.Contains(err.Error(), \"unable to get CWD from filesystem\") {\n\t\tlog.Print(\"CWD unavailable; set alloc_dir in client config\")\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["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."],"tags":["filesystem","fingerprinting","cwd"],"backgroundTag":"cwd-unavailable","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}