1
> install.packages(c("lubridate", "nlme", "readxl", "sourcetools", "utf8", "xfun"))
Installing packages into ‘C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)

  There are binary versions available but the source versions are later:
             binary  source needs_compilation
lubridate     1.9.1   1.9.2              TRUE
nlme        3.1-161 3.1-162              TRUE
readxl        1.4.1   1.4.2              TRUE
sourcetools   0.1.7 0.1.7-1              TRUE
utf8          1.2.2   1.2.3              TRUE
xfun           0.36    0.37              TRUE

installing the source packages ‘lubridate’, ‘nlme’, ‘readxl’, ‘sourcetools’, ‘utf8’, ‘xfun’

trying URL 'https://cran.rstudio.com/src/contrib/lubridate_1.9.2.tar.gz'
Content type 'application/x-gzip' length 427200 bytes (417 KB)
downloaded 417 KB

trying URL 'https://cran.rstudio.com/src/contrib/nlme_3.1-162.tar.gz'
Content type 'application/x-gzip' length 848546 bytes (828 KB)
downloaded 828 KB

trying URL 'https://cran.rstudio.com/src/contrib/readxl_1.4.2.tar.gz'
Content type 'application/x-gzip' length 2091835 bytes (2.0 MB)
downloaded 2.0 MB

trying URL 'https://cran.rstudio.com/src/contrib/sourcetools_0.1.7-1.tar.gz'
Content type 'application/x-gzip' length 24095 bytes (23 KB)
downloaded 23 KB

trying URL 'https://cran.rstudio.com/src/contrib/utf8_1.2.3.tar.gz'
Content type 'application/x-gzip' length 241412 bytes (235 KB)
downloaded 235 KB

trying URL 'https://cran.rstudio.com/src/contrib/xfun_0.37.tar.gz'
Content type 'application/x-gzip' length 130063 bytes (127 KB)
downloaded 127 KB

* installing *source* package 'lubridate' ...
** package 'lubridate' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c datetime.c -o datetime.o
/bin/sh: line 1: gcc: command not found
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:253: datetime.o] Error 127
ERROR: compilation failed for package 'lubridate'
* removing 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/lubridate'
* restoring previous 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/lubridate'
Warning in install.packages :
  installation of package ‘lubridate’ had non-zero exit status
* installing *source* package 'nlme' ...
** package 'nlme' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gfortran  -fno-optimize-sibling-calls    -O2  -mfpmath=sse -msse2 -mstackrealign  -c chol.f -o chol.o
make: gfortran: No such file or directory
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:277: chol.o] Error 127
ERROR: compilation failed for package 'nlme'
* removing 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/nlme'
* restoring previous 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/nlme'
Warning in install.packages :
  installation of package ‘nlme’ had non-zero exit status
* installing *source* package 'readxl' ...
** package 'readxl' successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -Iwindows -I. -D__USE_MINGW_ANSI_STDIO -I'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/cpp11/include' -I'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/progress/include'   -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c cpp11.cpp -o cpp11.o
/bin/sh: line 1: g++: command not found
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:260: cpp11.o] Error 127
ERROR: compilation failed for package 'readxl'
* removing 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/readxl'
* restoring previous 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/readxl'
Warning in install.packages :
  installation of package ‘readxl’ had non-zero exit status
* installing *source* package 'sourcetools' ...
** package 'sourcetools' successfully unpacked and MD5 sums checked
** using staged installation
** libs
g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG -I../inst/include    -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign  -c Reader.cpp -o Reader.o
/bin/sh: line 1: g++: command not found
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:260: Reader.o] Error 127
ERROR: compilation failed for package 'sourcetools'
* removing 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/sourcetools'
* restoring previous 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/sourcetools'
Warning in install.packages :
  installation of package ‘sourcetools’ had non-zero exit status
* installing *source* package 'utf8' ...
** package 'utf8' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"  -Iutf8lite/src   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c as_utf8.c -o as_utf8.o
/bin/sh: line 1: gcc: command not found
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:253: as_utf8.o] Error 127
ERROR: compilation failed for package 'utf8'
* removing 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/utf8'
* restoring previous 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/utf8'
Warning in install.packages :
  installation of package ‘utf8’ had non-zero exit status
* installing *source* package 'xfun' ...
** package 'xfun' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc  -I"C:/PROGRA~1/R/R-42~1.2/include" -DNDEBUG     -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"     -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2 -mstackrealign  -c base64.c -o base64.o
/bin/sh: line 1: gcc: command not found
make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:253: base64.o] Error 127
ERROR: compilation failed for package 'xfun'
* removing 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/xfun'
* restoring previous 'C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2/xfun'
Warning in install.packages :
  installation of package ‘xfun’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\Sachin Dahiya\AppData\Local\Temp\RtmpgBGXsJ\downloaded_packages’

I am using R version 4.2.2 and R tools43 on Windows 11. These packages have been asking for updates for a while now but the compliation fails every time. Please let me know how to fix this issue. I have instaled R tools and R.4.2.2 in C:\Program Files\R.

These are my paths:

> .libPaths()
[1] "C:/Users/Sachin Dahiya/AppData/Local/R/win-library/4.2"
[2] "C:/Program Files/R/R-4.2.2/library"  
Phil
  • 7,287
  • 3
  • 36
  • 66
  • "Rtools43 may be installed from the Rtools43 installer. It is recommended to use the defaults, including the default installation location of C:\rtools43." If building packages from source doesn't work, is there any reason why you can't use the previous versions until CRAN has build the binaries for the new versions? `install.packages(..., type = "binary")` – Roland Feb 10 '23 at 06:26

1 Answers1

0

First check which gcc R knows about via:

Sys.which('gcc')

If that doesn't provide a path, check R_RTOOLS42_PATH via

Sys.getenv('R_RTOOLS42_PATH')

It should be set to something like C:\<your rtools path>/x86_64-w64-mingw32.static.posix/bin:C:\<your rtools path>/usr/bin where the location you install Rtools is <your rtools path>.

If this hasn't be set, you could set the RTOOLS42_HOME environment variable. For the code behind how R 4.2 sets the R_RTOOLS42_PATH see: https://github.com/wch/r-source/blob/R-4-2-branch/src/library/profile/Rprofile.windows.

Alternatively to setting RTOOLS42_HOME, you can set R_RTOOLS42_PATH in your own Rprofile: see How to access and edit Rprofile? e.g. add the line

Sys.setenv('R_RTOOLS42_PATH'='C:/<your rtools path>/x86...') # as above

Note: This is all supposed to be unnecessary with the Rtools42 installer defaults, but I guess results may vary!

stephematician
  • 844
  • 6
  • 17