Installation error in IRanges for R 3.0 str_utils.c:158: error: ‘timezone’

I ran into this error on our HPC cluster when installing IRanges for R-3.0.0

gcc -std=c99 -L/usr/lib64 -L/source/gnu_4.4/lib64 -I/apps/source/R/R-3.0.0/R-3.0.0/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -o2 -c str_utils.c -o str_utils.o
str_utils.c: In function ‘get_svn_time’:
str_utils.c:156: warning: implicit declaration of function ‘tzset’
str_utils.c:158: error: ‘timezone’ undeclared (first use in this function)
str_utils.c:158: error: (Each undeclared identifier is reported only once
str_utils.c:158: error: for each function it appears in.)
make: *** [str_utils.o] Error 1
ERROR: compilation failed for package ‘IRanges’
* removing ‘/PHShome/ar474/R/x86_64-unknown-linux-gnu-library/3.0/IRanges’
WARNING: ignoring environment value of R_HOME
ERROR: dependency ‘IRanges’ is not available for package ‘XVector’
* removing ‘/PHShome/ar474/R/x86_64-unknown-linux-gnu-library/3.0/XVector’
WARNING: ignoring environment value of R_HOME
ERROR: dependencies ‘IRanges’, ‘XVector’ are not available for package ‘GenomicRanges’
* removing ‘/PHShome/ar474/R/x86_64-unknown-linux-gnu-library/3.0/GenomicRanges’  

This is annoying as there are packages in R that depend g on IRanges, For eg. GenomicRanges.   As I don’t have sysadmin privileges, nor do am I interested in reinstalling R from scratch locally, I did the following steps and the install worked:

  1. Download the IRanges package that is compatible with your version of R, in my case it was IRanges_1.22.9.tar.gz
  2. untar the package somewhere local which will unpack the package into folder called IRanges 
     tar -xvzf  IRanges_1.20.7.tar.gz 
  3. I then modified the following lines (156,158)of source code  in IRanges/src/
     vi IRanges/src/str_utils.c
      152 #if defined(__APPLE__) || defined(__FreeBSD__)
     153 //'struct tm' has no member named 'tm_gmtoff' on Windows+MinGW
     154 utc_offset = result.tm_gmtoff / 3600;
     155 #else /* defined(__APPLE__) || defined(__FreeBSD__) */
     156 tzset();
     157 //timezone is not portable (is a function, not a long, on OS X Tiger)
     158 utc_offset = - (timezone / 3600);
      152 #if defined(__APPLE__) || defined(__FreeBSD__)
     153 //'struct tm' has no member named 'tm_gmtoff' on Windows+MinGW
     154 utc_offset = result.tm_gmtoff / 3600;
     155 #else /* defined(__APPLE__) || defined(__FreeBSD__) */
     156 //tzset(); AR
     157 //timezone is not portable (is a function, not a long, on OS X Tiger)
     158 utc_offset = - (time(NULL) / 3600);
  4. Finally I re-tar gzipped the package
    tar -cvf IRanges.tar.gz IRanges
  5. And i now ran  local installation of the IRanges package I created
    > install.packages("~/downloads/IRanges.tar.gz") 
  6. The resulting installation message is
     Creating a generic function for ‘as.table’ from package ‘base’ in package ‘IRanges’
    Creating a generic function for ‘t’ from package ‘base’ in package ‘IRanges’
    ** help
    *** installing help indices
    ** building package indices
    ** installing vignettes
    ** testing if installed package can be loaded
    * DONE (IRanges)
    >

 

Advertisements

One thought on “Installation error in IRanges for R 3.0 str_utils.c:158: error: ‘timezone’

  1. Bless you. This seems like a strange thing to leave unfixed for so long. It’s STILL not fixed on Linux for BioC as of version 3.0 Your hack does work, tho the packages are now broken out a little differently. Thanks very much for documenting the fix.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s