diff --git a/src/ccutil/ccutil.cpp b/src/ccutil/ccutil.cpp index 7cf57f2ee9..483d5bc1ee 100644 --- a/src/ccutil/ccutil.cpp +++ b/src/ccutil/ccutil.cpp @@ -17,7 +17,8 @@ #include "ccutil.h" #include -#include // for std::strrchr +#include // for std::strrchrA +#include // for std::filesystem namespace tesseract { @@ -48,6 +49,12 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) { const char *tessdata_prefix = getenv("TESSDATA_PREFIX"); + // Ignore TESSDATA_PREFIX if there is no matching filesystem entry. + if (tessdata_prefix != nullptr && !std::filesystem::exists(tessdata_prefix)) { + tprintf("Warning: TESSDATA_PREFIX %s does not exist, ignore it\n", tessdata_prefix); + tessdata_prefix = nullptr; + } + if (!argv0.empty()) { /* Use tessdata prefix from the command line. */ datadir = argv0;