can1357/oh-my-pi · error · CatError
No such device or address
Error message
No such device or address
What it means
`CatError::NoSuchDeviceOrAddress` (unix-only) reports ENXIO — the path refers to a device special file but no device exists at that address, or the device cannot be opened in the requested mode. It is raised when opening/reading a character/block device yields this specific errno, letting `cat` print coreutils' exact wording instead of Rust's raw error string.
Source
Thrown at crates/pi-builtins/src/cat.rs:81
writer.write_all(self.to_str())
}
}
#[derive(Error, Debug)]
enum CatError {
/// Wrapper around `io::Error`.
#[error("{}", strip_errno(.0))]
Io(io::Error),
/// The downstream reader closed its pipe; this ends the copy quietly.
#[error("broken pipe")]
BrokenPipe,
/// Unknown file type; it is not a regular file, socket, or known device.
#[error("unknown filetype: {ft_debug}")]
UnknownFiletype { ft_debug: String },
#[error("Is a directory")]
IsDirectory,
#[cfg(unix)]
#[error("No such device or address")]
NoSuchDeviceOrAddress,
#[error("Too many levels of symbolic links")]
TooManySymlinks,
}
impl From<io::Error> for CatError {
fn from(error: io::Error) -> Self {
if error.kind() == ErrorKind::BrokenPipe {
Self::BrokenPipe
} else {
Self::Io(error)
}
}
}
fn strip_errno(error: &io::Error) -> String {
let mut message = error.to_string();
if let Some(position) = message.find(" (os error ") {View on GitHub (pinned to 9690622007)
Solutions
- Verify the device node is valid and its driver is loaded (`ls -l /dev/...`, `lsof`, kernel module list).
- In containers, mount/prepare the required device (e.g. --device with docker) before reading it.
- Don't cat device special files expecting data; use the appropriate tool (dd, socat) if you need device I/O.
Example fix
// before $ cat /dev/video0 cat: /dev/video0: No such device or address // after $ ls /dev/video* # ensure driver loaded / device attached $ dd if=/dev/video0 bs=1 count=1 # or use a v4l tool instead
Defensive patterns
Strategy: validation
Validate before calling
// shell: confirm the device node is present and readable before cat-ing DEV=/dev/video0 if [ ! -c "$DEV" ]; then echo "no such device node: $DEV" >&2; exit 1; fi if ! dd if="$DEV" of=/dev/null count=1 2>/dev/null; then echo "device not accessible: $DEV" >&2; exit 1 fi
Type guard
// Rust caller: match the specific errno variant
if matches!(err, CatError::NoSuchDeviceOrAddress) {
eprintln!("device not available at that address");
} Try / catch
// shell: degrade gracefully when a device is unavailable if ! cat -- "$DEV" 2>/dev/null; then echo "warning: $DEV unavailable, continuing" >&2 fi
Prevention
- Verify device nodes exist (driver loaded, device mounted in containers) before scripted access.
- Don't use cat for device I/O; prefer dd/socat with proper block sizes.
- In containers, explicitly pass through required devices at launch time.
When it happens
Trigger: `cat /dev/ttyX` where the tty has no controlling process; opening a device node whose driver/module is not loaded; `cat` on a unix socket path or special file that resolves to no live device (ENXIO from open/read).
Common situations: Scripts referencing /dev entries that only exist conditionally (missing kernel module, container without the device mounted); cat-ing device nodes that require exclusive or special open semantics; stale /dev paths after hardware changes.
Related errors
- unknown function: {0}
- unknown key binding function: {0}
- unimplemented: {0}
- I/O error occurred
- transparent (brush_parser::BindingParseError)
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/96eb842aac16d87f.
Report an issue: GitHub.