[Rd] RTools40 Error - sh: line 1: gcc: command not found

Gene Leynes g|eyne@ @end|ng |rom gm@||@com
Mon Nov 28 19:39:23 CET 2022


Hello,

I installed git bash for windows, R, RStudio, and R Tools on a fresh
Windows 10 machine.

I followed the directions for RTools:
https://cran.r-project.org/bin/windows/Rtools/rtools40.html

I added RTools to my user path, but I was getting an error when
installing jsonlite from source (even though it could find "make"
correctly). So, I tried the .Renviron method, and that didn't work either.

I was getting errors like this:

> install.packages("jsonlite", type = "source")
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://cloud.r-project.org/src/contrib/jsonlite_1.8.3.tar.gz'
Content type 'application/x-gzip' length 1053099 bytes (1.0 MB)
downloaded 1.0 MB


* installing *source* package 'jsonlite' ...
** package 'jsonlite' successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc  -I"C:/Users/XXXXXXX/AppData/Local/Programs/R/R-42~1.2/include"
-DNDEBUG -Iyajl/api
 -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include"
-D__USE_MINGW_ANSI_STDIO   -O2 -Wall  -std=gnu99 -mfpmath=sse -msse2
-mstackrealign  -c base64.c -o base64.o
sh: line 1: gcc: command not found
make: *** [C:/Users/ XXXXXXX
/AppData/Local/Programs/R/R-42~1.2/etc/x64/Makeconf:253:
base64.o] Error 127
ERROR: compilation failed for package 'jsonlite'
* removing
'C:/Users/375492/AppData/Local/Programs/R/R-4.2.2/library/jsonlite'


The downloaded source packages are in
        ‘C:\Users\ XXXXXXX
\AppData\Local\Temp\RtmpeCLXit\downloaded_packages’
Warning message:
In install.packages("jsonlite", type = "source") :
  installation of package ‘jsonlite’ had non-zero exit status


I can't reproduce this part, but at one point it said that gcc wasn't found
in C:\rtools40\mingw_64\bin (not sure where the underscore was, but it had
an underscore)

I noticed that my folder is named C:\rtools40\mingw64\bin

That gave me the idea to add C:\rtools40\mingw64\bin to my user path which
resolved the issues. Adding that to the path allowed me to compile from
source, etc. Fixed RStudio and the R GUI (whatever we call it now).

TLDR: I think there's a bug in the installer or something that creating an
incompatible path name with an underscore, or the instructions are missing
the advice to add C:\rtools40\mingw{WIN}\bin to the path.



Somewhat related:

By the way, I think adding RTools to the user path is the superior option
for Windows users, and I would like to propose an edit to that
documentation.

First, it will help avoid complications for users who may
experience different paths for ~ depending on network availability.

Second, it is a more standard way to edit the path and helps users learn
what's going on with the path and makes R less of a mysterious "exception
to the rule". No other program uses ~/.Renviron to edit the path.

Although it's worth mentioning the option to create ~/.Renviorn, it
shouldn't be the primary instruction.

Would it be possible to create a pull request for those edits? I don't know
where that documentation is maintained.


Thank you, and I hope you all are doing well.

	[[alternative HTML version deleted]]



More information about the R-devel mailing list