r-lib/tzdb

undefined symbol: lstat

Closed this issue · 4 comments

I report the error here below during the installation on my PC (Ubuntu OS)

Error: package or namespace load failed for ‘tzdb’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/user/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-tzdb/00new/tzdb/libs/tzdb.so':
/home/user/R/x86_64-pc-linux-gnu-library/4.2/00LOCK-tzdb/00new/tzdb/libs/tzdb.so: undefined symbol: lstat
Error: loading failed

Can you provide any other specifications on exactly what version of Ubuntu you are using?

Suppsedly lstat() is part of unistd.h and that is included by tz.cpp
https://manpages.ubuntu.com/manpages/xenial/man2/stat.2.html

tzdb/src/tz.cpp

Line 484 in 7173ffc

if (!(lstat(timezone, &sb) == 0 && S_ISLNK(sb.st_mode) && sb.st_size > 0))

https://github.com/r-lib/tzdb/blob/7173ffcb31af2ba217a086821263b7997e70b76f/src/tz.cpp#LL143C6-L143C6

@HowardHinnant you wouldn't happen to have any other guesses regarding why lstat() might be undefined in tz.cpp, would you?

It seems unlikely that we will get a response from the OP, and I haven't seen this anywhere else, so I will likely just close this, but wanted to at least make you aware of it first.

I'm not sure of the cause of this error either. But I note because it is not compile-time lstat must be declared. Just the definition is not found. This seems to me to point to a build environment error. E.g. didn't link to the proper shared lib or something like that.

After talking more with some others internally, our best guess is that this person has downloaded a binary version of tzdb that happened to be incompatible with their system, or compiled and installed tzdb on their system and then did a system upgrade / R upgrade and just copied over the old version of the package without recompiling, and this has caused some strange incompatibility.

Notably, this error is happening at package load time, not package compilation time, which leads us to think that.

We are optimistic that just reinstalling tzdb from source with pak::pak("r-lib/tzdb") will fix this, as that should ensure that the compiled package is compatible with your system.