1

I've recently installed R version 4.0.5 (2021-03-31) onto Ubuntu 20.04.2 LTS. R is working as expected.

However, while some packages have installed without issue (e.g., R.matlab), there are several packages that have not been able to install. As as example, running install.packages("data.table") throws the following error:

* installing *source* package ‘data.table’ ...
** package ‘data.table’ successfully unpacked and MD5 sums checked
** using staged installation
gcc -std=gnu99 9.3.0
zlib 1.2.11 is available ok
R CMD SHLIB supports OpenMP without any extra hint
** libs
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG     -fopenmp  -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-tRgc13/r-base-4.0.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c assign.c -o assign.o
during GIMPLE pass: ccp
assign.c: In function ‘memrecycle’:
assign.c:1205:1: internal compiler error: Segmentation fault
 1205 | }
      | ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-9/README.Bugs> for instructions.
make: *** [/usr/lib/R/etc/Makeconf:172: assign.o] Error 1
ERROR: compilation failed for package ‘data.table’

I get similar errors (i.e., "internal compiler error") with other package installation attempts, but with slightly different output. For example, install.packages("xfun") throws the following error, truncated for brevity:

gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG      -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-tRgc13/r-base-4.0.5=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c base64.c -o base64.o
during GIMPLE pass: ccp
base64.c: In function ‘base64_decode_impl’:
base64.c:237:1: internal compiler error: Segmentation fault
  237 | }
      | ^

I have tried reinstalling gcc-9, which has not helped. I had found that the PATH in Sys.getenv("PATH") was pointing to a miniconda3 install on my system, so updated that to /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/rstudio/bin/postback, which also has not helped.

My goal is to install packages among those above without throwing these compiler errors. Any help would be greatly appreciated.

  • Have you tried going into your library and just deleting off the folders with affected libraries manually? This is usually helpful for me when a package hits errors in installation. – Carey Caginalp Apr 17 '21 at 21:30
  • Congratulations! It looks like you have hit a bug in the GCC compiler. Maybe you should do what the output suggests and submit a bug report? – Striezel Apr 17 '21 at 23:24
  • @CareyCaginalp, the packages cannot even be installed, so there are no folders to delete manually--as far as I can tell. Striezel, since I'm relatively new to this, I wasn't sure if this was a "true" bug. I've posted a question to https://answers.launchpad.net/ubuntu under your suggestion. Thanks to you both. – Mazin Abdelghany Apr 18 '21 at 00:33

1 Answers1

1

In case others also run into this issue in the future, I am posting the solution that was suggested to me by https://answers.launchpad.net/ubuntu. Here is the link to the question I posted: https://answers.launchpad.net/ubuntu/+question/696623.

The issue turned out to be that R was using gcc-9 rather than gcc-10 to compile packages. The older version of gcc was throwing an error. Here are the steps I took to solve the problem:

  1. Install gcc-10, which was not available on my system: sudo apt install gcc-10.
  2. Edit the CC= pointer in the /usr/lib/R/etc/Makeconf file to gcc-10: open Terminal, type sudo nano /usr/lib/R/etc/Makeconf and replace the current CC= to CC=gcc-10. Save the file.
  3. Restart R and run the install.packages() command for those packages that were not compiling correctly.

EDIT: Please see the comments below for a discussion. The above steps resolve the issue, but are not recommended. The issue was related to R not using the system package manager to install packages when the call install.packages() was used in R.

Installing the package bspm solved the issue for me. This package and its utility is discussed here for those who are curious.

To use install.packages() within R, bspm can be used in two ways:

  1. bspm::enable() within R and then install.packages()
  2. As written in its documentation: To enable bspm system-wide by default, include the following: suppressMessages(bspm::enable()) into the Rprofile.site file.

Thanks very much to Dirk for his guidance.

  • Debian (and hence Ubuntu) maintainer for R here: the compiler has _nothing_ to do with this; we have upgraded those year after year after year and the they are (apart from one ABI changes a loooong time ag) *always* interchangeable. This simple is an answer that is somewhere between inapplicable, irrelevant and potentially misleading. Happy to discuss further on the r-sig-debian list for Debian and Ubuntu. – Dirk Eddelbuettel Apr 18 '21 at 18:08
  • @DirkEddelbuettel I'm surprised this is the case given that what I did solved the issue. I look forward to hearing your explanation. – Mazin Abdelghany Apr 19 '21 at 16:06
  • You did not "solve" anything, you likely used a big hammer to smother a likely unrelated issue. There simply is no general problem with _e.g._ `data.table` on Ubuntu, or for that matter another system, see https://cloud.r-project.org/web/checks/check_results_data.table.html (and ignore oldrel_macos for now). _If_ you have reproducible issue, please come to r-sig-debian and we help (or post here, I surmise quality of replies is better on the list even though I do course answer here too). – Dirk Eddelbuettel Apr 19 '21 at 16:10
  • And to reiterate: You are more likely to _do damage to your system_ by wildly editing config files are your "answer" here propose here. In general, do NOT do that. (You can override compilers too in `~/.R/Makevars` as shown here in dozens of answers; but as I said the compiler will have nothing to do with this.) – Dirk Eddelbuettel Apr 19 '21 at 16:12
  • In the twenty-five years I have looked after this, I encountered two or three genuine compiler errors _on development versions of the compiler_. If a released version croaks as for you here it is ... most likely for lack of ram or other (local !!) system resources. And even then, Linux generally copes really well. – Dirk Eddelbuettel Apr 19 '21 at 16:13
  • 1
    Apologies for my misunderstanding. After reverting the Makeconf file to its original contents, I am still having the above issue with installing packages. I will post to r-sig-debian. – Mazin Abdelghany Apr 19 '21 at 16:41
  • You need to subscribe to post so make sure you subscribe first. See you there! – Dirk Eddelbuettel Apr 19 '21 at 16:43