You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "irisjae (via GitHub)" <gi...@apache.org> on 2025/08/16 16:19:46 UTC

[I] Timezone logic on Linux and Mac [arrow]

irisjae opened a new issue, #47347:
URL: https://github.com/apache/arrow/issues/47347

   ### Describe the bug, including details regarding any error messages, version, and platform.
   
   In pyarrow, I've been getting `pyarrow.lib.ArrowInvalid: Cannot locate timezone 'UTC': discover_tz_dir failed to find zoneinfo` despite my timezone appearing to be properly setup. I seem to have tracked down the problem due to a mixup in the timezone discovery logic (introduced by 67850befa604ce27c2ea8f37132a5ccf73fe68d9?)
   
   As of now, [cpp/src/arrow/vendored/datetime/tz.cpp](https://github.com/apache/arrow/blob/67850befa604ce27c2ea8f37132a5ccf73fe68d9/cpp/src/arrow/vendored/datetime/tz.cpp) contains such logic to find zoneinfo:
   
   ```
   discover_tz_dir()
   {
      ...
   #  elif !defined(__APPLE__)
       CONSTDATA auto tz_dir_default = "/usr/share/zoneinfo";
       CONSTDATA auto tz_dir_buildroot = "/usr/share/zoneinfo/uclibc";
   
       // Check special path which is valid for buildroot with uclibc builds
       if(stat(tz_dir_buildroot, &sb) == 0 && S_ISDIR(sb.st_mode))
           return tz_dir_buildroot;
       else if(stat(tz_dir_default, &sb) == 0 && S_ISDIR(sb.st_mode))
           return tz_dir_default;
       else
           throw runtime_error("discover_tz_dir failed to find zoneinfo\n");
   #  else  // __APPLE__
   #      if TARGET_OS_IPHONE
   #          if TARGET_OS_SIMULATOR
       return "/usr/share/zoneinfo";
   #          else
       return "/var/db/timezone/zoneinfo";
   #          endif
   #      else
       CONSTDATA auto timezone = "/etc/localtime";
   ```
   
   As far as I can tell, macOS contains zoneinfo in `/usr/share/zoneinfo` and Linux contains zoneinfo in somewhere like `/etc/zoneinfo` symlinked from `/etc/localtime`. However, according to the above logic, zoneinfo is searched for in `/usr/share/zoneinfo` if the system is NOT Apple (i.e. Linux).
   
   In my Python application, I've managed to workaround this issue for the time being by making a cgroup with `/etc/zoneinfo` bind mounted to `/usr/share/zoneinfo` using bubblewrap.
   
   ### Component(s)
   
   Python, C++


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org