DrKLO/Telegram · error
%s: can't open %s
Error message
%s: can't open %s
What it means
rdjpgcom attempts to fopen the user-specified input file in binary read mode (READ_BINARY). If fopen returns NULL, the file could not be opened -- typically because it does not exist, permissions are insufficient, or the path is a directory. The program prints this error with the file path and exits with EXIT_FAILURE.
Source
Thrown at TMessagesProj/jni/mozjpeg/rdjpgcom.c:487
break; /* not switch, must be file name */
arg++; /* advance over '-' */
if (keymatch(arg, "verbose", 1)) {
verbose++;
} else if (keymatch(arg, "raw", 1)) {
raw = 1;
} else
usage();
}
/* Open the input file. */
/* Unix style: expect zero or one file name */
if (argn < argc - 1) {
fprintf(stderr, "%s: only one input file\n", progname);
usage();
}
if (argn < argc) {
if ((infile = fopen(argv[argn], READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
exit(EXIT_FAILURE);
}
} else {
/* default input file is stdin */
#ifdef USE_SETMODE /* need to hack file mode? */
setmode(fileno(stdin), O_BINARY);
#endif
#ifdef USE_FDOPEN /* need to re-open in binary mode? */
if ((infile = fdopen(fileno(stdin), READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open stdin\n", progname);
exit(EXIT_FAILURE);
}
#else
infile = stdin;
#endif
}
/* Scan the JPEG headers. */View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the file exists and is readable: ls -la <path> or test -r <path>.
- Check the full path for typos and correct relative/absolute path usage.
- Fix file permissions: chmod +r <path> or ensure the running user has access.
- If the path is a directory, remove it or pass the actual file path.
Example fix
# before rdjpgcom /wrong/path/image.jpg # after rdjpgcom ./images/image.jpg
Defensive patterns
Strategy: validation
Validate before calling
# Check file exists and is readable before invoking rdjpgcom if [ ! -r "$input" ]; then echo "Error: cannot read $input" >&2 exit 1 fi rdjpgcom "$input"
Prevention
- Use test -r <path> to verify readability before passing to CLI tools.
- Use absolute paths to avoid working-directory ambiguity.
- Check file permissions with ls -la when debugging access errors.
When it happens
Trigger: Passing a file path that does not exist; a path with insufficient read permissions; a path that is a directory rather than a file; a path with incorrect escaping or quoting in the shell.
Common situations: Typo in the filename; relative path used from the wrong working directory; file on an unmounted or disconnected volume; file owned by another user with no read access; Android environment where the path is in a protected directory.
Related errors
- %s: can't open stdin
- Can't open table file %s
- Can't open scan definition file %s
- %s: sorry, arithmetic coding not supported
- %s: missing argument for dct
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/57bc379aab0e35f2.
Report an issue: GitHub.