What does errno 2 (ENOENT) mean?

 
Could be also:
ConstantTypeOS
ERROR_FILE_NOT_FOUNDWin32 errorWindows
STATUS_WAIT_2NTSTATUSWindows
KERN_PROTECTION_FAILUREKern returnMac
ippStsMisalignedBufIntel Ipp StatusAny
WDSMCCLIENT_CATEGORYHRESULTWindows
DEVICE_QUEUE_NOT_BUSYBugCheck CodeWindows
Previous Next
EPERM ESRCH

ENOENT

Why “file not found” can be misleading

ENOENT does not prove that the final filename was misspelled. Path resolution walks every component between the starting directory and the final name. The result can therefore mean that an intermediate directory is missing, a symbolic link is dangling, the current working directory is not what the program assumed, or a required interpreter or loader cannot be found while starting an executable.

Relative paths deserve special attention in services, scheduled jobs, containers, and IDE launch configurations. They are resolved from the process working directory, not from the executable’s directory. An openat()-style API can instead interpret a relative path from a supplied directory descriptor.

How to investigate

  • Log the exact path after variable expansion and record the current working directory or directory descriptor used by the call.
  • Check every path component, including symlink targets and mount points, rather than checking only the leaf name.
  • For an execution failure, inspect the script interpreter line and the executable’s dynamic-loader and library dependencies.
  • When a file is expected to appear asynchronously, distinguish a genuine race from a permanent configuration error before retrying.

References


Looking for a different code? Search another status or error code.