{"record":{"id":"a4116ffd7eb633cd","repo":"Yalantis/uCrop","slug":"load-gzip-external-failed-to-open-file-s","errorCode":null,"errorMessage":"load_gzip_external(): Failed to open file '%s'.","messagePattern":"load_gzip_external\\(\\): Failed to open file '(.+?)'\\.","errorType":"exception","errorClass":"CImgIOException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":67597,"sourceCode":"      do {\n        if (!cimg::strcasecmp(ext,\"gz\")) {\n          if (*ext2) cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s.%s\",\n                                   cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext2);\n          else cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s\",\n                             cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());\n        } else {\n          if (*ext) cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s.%s\",\n                                  cimg::temporary_path(),cimg_file_separator,cimg::filenamerand(),ext);\n          else cimg_snprintf(filename_tmp,filename_tmp._width,\"%s%c%s\",\n                             cimg::temporary_path(),cimg_file_separator,cimg::filenamerand());\n        }\n      } while (cimg::path_exists(filename_tmp));\n      cimg_snprintf(command,command._width,\"\\\"%s\\\" -c \\\"%s\\\" > \\\"%s\\\"\",\n                    cimg::gunzip_path(),\n                    CImg<charT>::string(filename)._system_strescape().data(),\n                    CImg<charT>::string(filename_tmp)._system_strescape().data());\n      if (cimg::system(command,cimg::gunzip_path())!=0)\n        throw CImgIOException(_cimglist_instance\n                              \"load_gzip_external(): Failed to open file '%s'.\",\n                              cimglist_instance,\n                              filename);\n      if (!cimg::path_exists(filename_tmp)) {\n        cimg::fclose(cimg::fopen(filename,\"r\"));\n        throw CImgIOException(_cimglist_instance\n                              \"load_gzip_external(): Failed to open file '%s'.\",\n                              cimglist_instance,\n                              filename);\n\n      }\n      load(filename_tmp);\n      std::remove(filename_tmp);\n      return *this;\n    }\n\n    //! Load a gzipped list, using external tool 'gunzip' \\newinstance.\n    static CImgList<T> get_load_gzip_external(const char *const filename) {","sourceCodeStart":67579,"sourceCodeEnd":67615,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L67579-L67615","documentation":"load_gzip_external() builds a command line like \"gunzip\" -c \"file.gz\" > tmpfile and runs it via cimg::system(). If that external command returns a nonzero exit status, CImg throws this CImgIOException. It means the gunzip process itself failed (tool missing, corrupt archive, permissions), even though the input file existed.","triggerScenarios":"cimg::system() returns !=0 after running cimg::gunzip_path() on the file; gunzip binary not installed; corrupted .gz; no write permission for the temp file directory.","commonSituations":"Deployed containers/images without the gzip package; gunzip path misconfigured; truncated or corrupt archive produced by a failed download; sandboxed app without temp dir write access.","solutions":["Install or verify the gunzip tool and ensure cimg::gunzip_path() points to it (check environment variable/compile-time path).","Test decompression manually (gunzip -t file.gz) to rule out a corrupt archive.","Ensure the temp directory (CImg tmpdir) is writable by the process."],"exampleFix":"// before\nlist.load_gzip_external(\"data.bin.gz\"); // fails silently when gunzip absent\n// after\nif (std::system(\"command -v gunzip >/dev/null\")!=0)\n  throw std::runtime_error(\"gunzip not installed\");\nlist.load_gzip_external(\"data.bin.gz\");","handlingStrategy":"fallback","validationCode":"if (std::system(\"command -v gunzip >/dev/null 2>&1\") != 0) {\n  fprintf(stderr, \"gunzip not available\\n\");\n  return false;\n}","typeGuard":null,"tryCatchPattern":"try { list.load_gzip_external(path); }\ncatch (CImgIOException &e) { /* fall back to CImg's built-in gz loader or error out */ }","preventionTips":["Ship/verify the gzip package in your deployment image.","Test archives with gunzip -t before loading.","Keep CImg's gunzip_path() config correct."],"tags":["gzip","external-process","io"],"backgroundTag":"external-command-failed","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}