*** caught segfault *** Traceback is giving nothing.

I have caught a segfault while trying to do an update.packages. A bit of googling has not helped much except to suggest I have a bug in "some" package. It appears that rnaturalearth is going to be a dependency in some spatial programs I have installed.

I did try removing rnaturalearth, rebooting the computer and reinstalling with no luck.

Traceback is giving nothing.

SessionInfo is below but I am on Ubuntu 22.04, with R version 4.2.2 Patched and RStudio 2022.07.2+576 "Spotted Wakerobin"

traceback(install.packages("rnaturalearth"))
Installing package into ‚Äė/home/john/R/x86_64-pc-linux-gnu-library/4.2‚Äô
(as ‚Äėlib‚Äô is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rnaturalearth_0.3.2.tar.gz'
Content type 'application/x-gzip' length 747688 bytes (730 KB)
==================================================
downloaded 730 KB

* installing *source* package ‚Äėrnaturalearth‚Äô ...
** package ‚Äėrnaturalearth‚Äô successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading

 *** caught segfault ***
address 0x559c7d57e7ff, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault (core dumped)
ERROR: lazy loading failed for package ‚Äėrnaturalearth‚Äô
* removing ‚Äė/home/john/R/x86_64-pc-linux-gnu-library/4.2/rnaturalearth‚Äô
Warning in install.packages :
  installation of package ‚Äėrnaturalearth‚Äô had non-zero exit status

The downloaded source packages are in
	‚Äė/tmp/RtmpSqY2Iw/downloaded_packages‚Äô
3: .is.positive.intlike(x)
2: .traceback(x, max.lines = max.lines)
1: traceback(install("rnaturalearth"))

And

sessionInfo() 
R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C               LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8    LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.2.2 tools_4.2.2    remotes_2.4.2 

What's your version of GDAL?

Never heard of it.

Just installed GDAL 3.6.2, released 2023/01/02 and rebooted.

Same problem

 installing *source* package ‚Äėrnaturalearth‚Äô ...
** package ‚Äėrnaturalearth‚Äô successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading

 *** caught segfault ***
address 0x564d830b4bd0, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault (core dumped)
ERROR: lazy loading failed for package ‚Äėrnaturalearth‚Äô
* removing ‚Äė/home/john/R/x86_64-pc-linux-gnu-library/4.2/rnaturalearth‚Äô
Warning in install.packages :
  installation of package ‚Äėrnaturalearth‚Äô had non-zero exit status

The downloaded source packages are in
	‚Äė/tmp/Rtmpa0NWtv/downloaded_packages‚Äô
No traceback available 

I am getting the same error message trying to install from R as from within RStudio.

Thanks.

This error is coming from the C++ compiler, what are your g++ \ gcc versions?

A walkaround could be installing a binary from the Public Posit Package Manager

Thanks andresrcs

It seems to be:

gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

A walkaround could be installing a binary from the Public Posit Package Manager

Ouch! Can you point me to any guidelines on this?

Sure, check the documentation to setup PPM as your package source

https://packagemanager.rstudio.com/client/#/repos/2/overview

I think I am misread something here. You are suggesting installing the R package "rnaturalearth* from Public Posit Package Manager ? I read that, originally as as installing gcc from there.

Given I seem to have a wonky c++ compiler, would I be better off re-installing it?

Yes, since PPM offers binaries for Ubuntu you won't need to compile it

gcc is not an R package, it's a system library and PPM is not a deb source.

You have a modern enough version of the compiler, I think the problem could be with the configured build options either on your side (env vars) or in the package code itself.

Oh, I think I see now. Thanks.

I'll leave this open just in case I manage to destroy the computer while trying to insall the package.

Thanks

So far I have not melted down thoe computer but that is as far as I have gotten. I suspect that I am completely misunderstanding one or more of the instructions or you are correct that I have something messed up in my env vars.

I have gone to the Public Posit Package Manager which suggests that I want to use

https://packagemanager.rstudio.com/cran/__linux__/jammy/latest

as my repository
I then tried in sequenco

install.packages('rnaturalearth')

Error as before

install.packages('rnaturalearth', type = "binary")

install.packages('rnaturalearth', type = "binary")
Error in install.packages : type 'binary' is not supported on this platform

And a rather desperate 

install.packages('rnaturalearth', type = 'source')

It occurs to me that the warning sign in the screenshot may be hinting at a problem but it has been there for several months.

The package repository is likely being overwrite by a startup file (Rprofile.site or .Rprofile) because I just checked and there is a binary of rnaturalearth for Ubuntu 22.04 LTS

Ah, thanks. Can I just kill one or both of those? I, literally, have not edited one in 15 years.

I can't predict the consequences on your R setup without seeing the content.

So far I have found two but I cannot find a .Rprofile file. I thought it should be at root level but I do not see it.
/etc/R

##						Emacs please make this -*- R -*-
## empty Rprofile.site for R on Debian
##
## Copyright (C) 2008 - 2018  Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Rprofile and Rprofile.site

# ## Example of .Rprofile
# options(width=65, digits=5)
# options(show.signif.stars=FALSE)
# setHook(packageEvent("grDevices", "onLoad"),
#         function(...) grDevices::ps.options(horizontal=FALSE))
# set.seed(1234)
# .First <- function() cat("\n   Welcome to R!\n\n")
# .Last <- function()  cat("\n   Goodbye!\n\n")

# ## Example of Rprofile.site
# local({
#  # add MASS to the default packages, set a CRAN mirror
#  old <- getOption("defaultPackages"); r <- getOption("repos")
#  r["CRAN"] <- "http://my.local.cran"
#  options(defaultPackages = c(old, "MASS"), repos = r)
#})

## We set the cloud mirror, which is 'network-close' to everybody, as default
local({
    r <- getOption("repos")
    r["CRAN"] <- "https://cloud.r-project.org"
    options(repos = r)
})

/usr/lib/R/etc

##						Emacs please make this -*- R -*-
## empty Rprofile.site for R on Debian
##
## Copyright (C) 2008 - 2018  Dirk Eddelbuettel and GPL'ed
##
## see help(Startup) for documentation on ~/.Rprofile and Rprofile.site

# ## Example of .Rprofile
# options(width=65, digits=5)
# options(show.signif.stars=FALSE)
# setHook(packageEvent("grDevices", "onLoad"),
#         function(...) grDevices::ps.options(horizontal=FALSE))
# set.seed(1234)
# .First <- function() cat("\n   Welcome to R!\n\n")
# .Last <- function()  cat("\n   Goodbye!\n\n")

# ## Example of Rprofile.site
# local({
#  # add MASS to the default packages, set a CRAN mirror
#  old <- getOption("defaultPackages"); r <- getOption("repos")
#  r["CRAN"] <- "http://my.local.cran"
#  options(defaultPackages = c(old, "MASS"), repos = r)
#})

## We set the cloud mirror, which is 'network-close' to everybody, as default
local({
    r <- getOption("repos")
    r["CRAN"] <- "https://cloud.r-project.org"
    options(repos = r)
})



Look for .Rprofile in ~

This line sets your package repository and it overwrites your RStudio settings.

It would be safe to delete any .Rprofile file since those are usually user authored. But the Rprofile.site file comes with the R installation so that one you should just edit if needed, it should be locates at R_HOME/etc being R_HOME the installation directory.

Ah, thank you.

Am I save to remove just the on line or should I remove

    r <- getOption("repos")
    r["CRAN"] <- "https://cloud.r-project.org"
    options(repos = r)

Nothing. Lots of hidden files but not .Rprofile.

Then that's not the problem.