Lubridate: Unable to install lubridate package in R

Created on 19 Jun 2018  Â·  5Comments  Â·  Source: tidyverse/lubridate

Am using R 3.5 version, while am trying to install the lubridate package in rstudio its throws an error as follows

install.packages("lubridate")
Installing package into ‘/home/Arun/R/x86_64-redhat-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/lubridate_1.7.4.tar.gz'

Content type 'application/x-gzip' length 449850 bytes (439 KB)

downloaded 439 KB

  • installing source package ‘lubridate’ ...
    * package ‘lubridate’ successfully unpacked and MD5 sums checked
    *
    libs
    g++ -m64 -std=gnu++0x -I"/usr/include/R" -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c RcppExports.cpp -o RcppExports.o
    gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC -c datetime.c -o datetime.o
    gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC -c period.c -o period.o
    gcc -m64 -std=gnu99 -I"/usr/include/R" -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic -fPIC -c tparse.c -o tparse.o
    g++ -m64 -std=gnu++0x -I"/usr/include/R" -DNDEBUG -I. -I./cctz/include/ -I./cctz/src/ -I"/usr/lib64/R/library/Rcpp/include" -I/usr/local/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c update.cpp -o update.o
    In file included from ./cctz/include/civil_time.h:18,
    from update.cpp:4:
    ./cctz/include/civil_time_detail.h:37: error: expected nested-name-specifier before ‘year_t’
    ./cctz/include/civil_time_detail.h:37: error: ‘year_t’ has not been declared
    ./cctz/include/civil_time_detail.h:37: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:37: error: expected unqualified-id before ‘=’ token
    ./cctz/include/civil_time_detail.h:41: error: expected nested-name-specifier before ‘diff_t’
    ./cctz/include/civil_time_detail.h:41: error: ‘diff_t’ has not been declared
    ./cctz/include/civil_time_detail.h:41: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:41: error: expected unqualified-id before ‘=’ token
    ./cctz/include/civil_time_detail.h:46: error: expected nested-name-specifier before ‘month_t’
    ./cctz/include/civil_time_detail.h:46: error: ‘month_t’ has not been declared
    ./cctz/include/civil_time_detail.h:46: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:46: error: expected unqualified-id before ‘=’ token
    ./cctz/include/civil_time_detail.h:47: error: expected nested-name-specifier before ‘day_t’
    ./cctz/include/civil_time_detail.h:47: error: ‘day_t’ has not been declared
    ./cctz/include/civil_time_detail.h:47: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:47: error: expected unqualified-id before ‘=’ token
    ./cctz/include/civil_time_detail.h:48: error: expected nested-name-specifier before ‘hour_t’
    ./cctz/include/civil_time_detail.h:48: error: ‘hour_t’ has not been declared
    ./cctz/include/civil_time_detail.h:48: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:48: error: expected unqualified-id before ‘=’ token
    ./cctz/include/civil_time_detail.h:49: error: expected nested-name-specifier before ‘minute_t’
    ./cctz/include/civil_time_detail.h:49: error: ‘minute_t’ has not been declared
    ./cctz/include/civil_time_detail.h:49: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:49: error: expected unqualified-id before ‘=’ token
    ./cctz/include/civil_time_detail.h:50: error: expected nested-name-specifier before ‘second_t’
    ./cctz/include/civil_time_detail.h:50: error: ‘second_t’ has not been declared
    ./cctz/include/civil_time_detail.h:50: error: expected ‘;’ before ‘=’ token
    ./cctz/include/civil_time_detail.h:50: error: expected unqualified-id before ‘=��� token
    ./cctz/include/civil_time_detail.h:54: error: expected ‘)’ before ‘year’
    ./cctz/include/civil_time_detail.h:78: error: ‘cctz::detail::impl::is_leap_year’ declared as an ‘inline’ variable
    ./cctz/include/civil_time_detail.h:78: error: ‘year_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:78: error: expected ‘,’ or ‘;’ before ‘noexcept’
    ./cctz/include/civil_time_detail.h:81: error: ‘cctz::detail::impl::year_index’ declared as an ‘inline’ variable
    ./cctz/include/civil_time_detail.h:81: error: ‘year_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:81: error: ‘month_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:81: error: initializer expression list treated as compound expression
    ./cctz/include/civil_time_detail.h:81: error: expected ‘,’ or ‘;’ before ‘noexcept’
    ./cctz/include/civil_time_detail.h:84: error: ‘cctz::detail::impl::days_per_century’ declared as an ‘inline’ variable
    ./cctz/include/civil_time_detail.h:84: error: ‘year_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:84: error: ‘month_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:84: error: initializer expression list treated as compound expression
    ./cctz/include/civil_time_detail.h:84: error: expected ‘,’ or ‘;’ before ‘noexcept’
    ./cctz/include/civil_time_detail.h:88: error: ‘cctz::detail::impl::days_per_4years’ declared as an ‘inline’ variable
    ./cctz/include/civil_time_detail.h:88: error: ‘year_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:88: error: ‘month_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:88: error: initializer expression list treated as compound expression
    ./cctz/include/civil_time_detail.h:88: error: expected ‘,’ or ‘;’ before ‘noexcept’
    ./cctz/include/civil_time_detail.h:92: error: ‘cctz::detail::impl::days_per_year’ declared as an ‘inline’ variable
    ./cctz/include/civil_time_detail.h:92: error: ‘year_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:92: error: ‘month_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:92: error: initializer expression list treated as compound expression
    ./cctz/include/civil_time_detail.h:92: error: expected ‘,’ or ‘;’ before ‘noexcept’
    ./cctz/include/civil_time_detail.h:95: error: ‘cctz::detail::impl::days_per_month’ declared as an ‘inline’ variable
    ./cctz/include/civil_time_detail.h:95: error: ‘year_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:95: error: ‘month_t’ was not declared in this scope
    ./cctz/include/civil_time_detail.h:95: error: initializer expression list treated as compound expression
    ./cctz/include/civil_time_detail.h:95: error: expected ‘,’ or ‘;’ before ‘noexcept’
    In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/functional:56,
    from /usr/lib64/R/library/Rcpp/include/RcppCommon.h:70,
    from /usr/lib64/R/library/Rcpp/include/Rcpp.h:27,
    from update.cpp:7:
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/typeinfo:36: error: expected ‘}’ before end of line
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/typeinfo:36: error: expected ‘}’ before end of line
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/typeinfo:36: error: expected ‘}’ before end of line
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/typeinfo:36: error: expected declaration before end of line
    make: * [update.o] Error 1
    ERROR: compilation failed for package ‘lubridate’
  • removing ‘/home/Arun/R/x86_64-redhat-linux-gnu-library/3.5/lubridate’
    Warning in install.packages :
    installation of package ‘lubridate’ had non-zero exit status

The downloaded source packages are in
‘/tmp/RtmpSIz8vF/downloaded_packages’

Kindly someone help to resolve this problem
thanks in advance

Most helpful comment

Here is what I do on CentOS 6.9 in order to install the latest version of lubridate which requires a gcc version later than what comes with CentOS 6.9.

  1. Install devtoolset-3
    sudo yum install centos-release-scl-rh
    sudo yum install devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-gcc-gfortran

  2. Start a new bash shell with devtoolset-3 enabled (because the above steps do not replace the default gcc)
    scl enable devtoolset-3 bash

  3. From that shell, run your R code again and the lubridate package will be successfully downloaded and compiled to your library.

When you return to your normal shell, without the devtoolset-3 enabled, you will still be able to run your R code because the package will already be compiled, as long as you are using the same library directory.

All 5 comments

Same here I am not able to install it on debian:stretch

You need newer version of gcc (4.8.0, better 4.9.0). There are several issues on this tracker with similar problem. Some of them have concrete (admittedly technical) directions.

You could also install an old version. Tested on my CentOS 6.9:

wget https://github.com/tidyverse/lubridate/archive/v1.6.0.tar.gz
sudo R CMD INSTALL v1.6.0.tar.gz

I tried the below command and its working fine
wget https://github.com/tidyverse/lubridate/archive/v1.6.0.tar.gz
sudo R CMD INSTALL v1.6.0.tar.gz

Here is what I do on CentOS 6.9 in order to install the latest version of lubridate which requires a gcc version later than what comes with CentOS 6.9.

  1. Install devtoolset-3
    sudo yum install centos-release-scl-rh
    sudo yum install devtoolset-3-gcc devtoolset-3-gcc-c++ devtoolset-3-gcc-gfortran

  2. Start a new bash shell with devtoolset-3 enabled (because the above steps do not replace the default gcc)
    scl enable devtoolset-3 bash

  3. From that shell, run your R code again and the lubridate package will be successfully downloaded and compiled to your library.

When you return to your normal shell, without the devtoolset-3 enabled, you will still be able to run your R code because the package will already be compiled, as long as you are using the same library directory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vspinu picture vspinu  Â·  6Comments

rachaelmburke picture rachaelmburke  Â·  55Comments

dominicroye picture dominicroye  Â·  9Comments

rappster picture rappster  Â·  10Comments

Teebusch picture Teebusch  Â·  3Comments