Cannot install xfun

I am using Windows 10. I was having problems with the newest version of RStudio. I was getting a black screen and also sometimes a blue dot. This caused me to reboot my system.
So I installed the latest version of R and reinstalled RStudio.
I had to reinstall my packages.
I am now trying to use RMarkdown, but I have to install xfun. However, when I try to do that I get the error message
“In install.packages("xfun") : installation of package ‘xfun’ had non-zero exit status”

I cannot install from RGui either. I have RTools on my computer.
I have been using R and RStudio for years and never had these problems. Now I am having many problems. I wonder if I have a registry problem.

I am using R version 4.2.2 (2022-10-31 ucrt) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

RStudio 2022.12.0+353 "Elsbeth Geranium" Release (7d165dcfc1b6d300eb247738db2c7076234f6ef0, 2022-12-03) for Windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2022.12.0+353 Chrome/102.0.5005.167 Electron/19.1.3 Safari/537.36

** Installing R Package Dependencies for R Markdown: 'markdown', 'xfun'

[1/2] Installing xfun...

Installing package into 'C:/Users/irash/AppData/Local/R/win-library/4.2'
(as 'lib' is unspecified)

There is a binary version available but the source version is later:
binary source needs_compilation
xfun 0.36 0.37 TRUE

installing the source package 'xfun'

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 '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
    sh: 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/irash/AppData/Local/R/win-library/4.2/xfun'

[2/2] Installing markdown...

The downloaded source packages are in
'C:\Users\irash\AppData\Local\Temp\Rtmpmi0RId\downloaded_packages'
Installing package into 'C:/Users/irash/AppData/Local/R/win-library/4.2'
(as 'lib' is unspecified)
also installing the dependency 'xfun'

There are binary versions available but the source versions are later:
binary source needs_compilation
xfun 0.36 0.37 TRUE
markdown 1.4 1.5 FALSE

installing the source packages 'xfun', 'markdown'

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

trying URL 'https://cran.rstudio.com/src/contrib/markdown_1.5.tar.gz'
Content type 'application/x-gzip' length 41683 bytes (40 KB)

downloaded 40 KB

  • 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
    sh: 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/irash/AppData/Local/R/win-library/4.2/xfun'
    ERROR: dependency 'xfun' is not available for package 'markdown'
  • removing 'C:/Users/irash/AppData/Local/R/win-library/4.2/markdown'

The downloaded source packages are in
'C:\Users\irash\AppData\Local\Temp\Rtmpmi0RId\downloaded_packages'

:heavy_check_mark: Packages successfully installed.
Warning messages:
1: In utils::install.packages("xfun", repos = "https://cran.rstudio.com/") :
installation of package 'xfun' had non-zero exit status
2: In utils::install.packages("markdown", repos = "https://cran.rstudio.com/") :
installation of package 'xfun' had non-zero exit status
3: In utils::install.packages("markdown", repos = "https://cran.rstudio.com/") :
installation of package 'markdown' had non-zero exit status

Here is another problem. I wonder if it is related.
Installing 'ggrepel' ...

Installing package into 'C:/Users/irash/AppData/Local/R/win-library/4.2'
(as 'lib' is unspecified)

There is a binary version available but the source version is later:
binary source needs_compilation
ggrepel 0.9.2 0.9.3 TRUE

installing the source package 'ggrepel'

trying URL 'https://cran.rstudio.com/src/contrib/ggrepel_0.9.3.tar.gz'
Content type 'application/x-gzip' length 136189 bytes (132 KB)

downloaded 132 KB

  • installing source package 'ggrepel' ...
    ** package 'ggrepel' 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'C:/Users/irash/AppData/Local/R/win-library/4.2/Rcpp/include' -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
    sh: g++: command not found
    make: *** [C:/PROGRA~1/R/R-42~1.2/etc/x64/Makeconf:260: RcppExports.o] Error 127
    ERROR: compilation failed for package 'ggrepel'
  • removing 'C:/Users/irash/AppData/Local/R/win-library/4.2/ggrepel'

The downloaded source packages are in
'C:\Users\irash\AppData\Local\Temp\RtmpGQsmOw\downloaded_packages'

:heavy_check_mark: Package 'ggrepel' successfully installed.
Warning message:
In utils::install.packages("ggrepel", repos = "https://cran.rstudio.com/") :
installation of package 'ggrepel' had non-zero exit status

Any ideas?

Probably needs the path containing gcc to be in your windows evironment variables/paths

Thanks. Can you please provide more details on what I need to do? Background. After I installed the latest version of R and then reinstalled RStudio, RStudio did not auto-detect the latest version of R. I had to manually make the change.

use windows search to identify where the gcc.exe you would wish to use is found.

make a note of the path

Then open up the windows menu; type as much of 'edit environment variables for your account` as you need to for that option to come up and choose it;
choose Path; edit; and add the new entry


you may need to restart your windows session

Thank you very much for your detailed explanation.
I added the following to my path and rebooted my computer a second time because I got a black screen again.
C:\rtools40\mingw64\bin

I tried to knit as PDF. I received the error message that namespace load failed for tidyverse.
There is no package called UTF8
Then I got this

install.packages("utf8")
Installing package into ‘C:/Users/irash/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)

There is a binary version available but the source version is later:
binary source needs_compilation
utf8 1.2.2 1.2.3 TRUE

I also got a pop up about installing packages that need compilation.
I then had to install tinytex.
Eventually, the packages were installed.
I then tried to kinit as PDF and got the following but no PDF file

processing file: TurnerMachadoknit.Rmd

"C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS TurnerMachadoknit.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output TurnerMachadoknit.tex --lua-filter "C:\Users\irash\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\irash\AppData\Local\R\win-library\4.2\rmarkdown\rmarkdown\lua\latex-div.lua" --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in"
output file: TurnerMachadoknit.knit.md

Also the process did not complete as there was a red stop button which did not work.
After closing and then opening RStudio, I was able to knit to HTML and to Word (but not the current version of Word).

Any ideas on how to knit to PDF?
Thanks again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.