Dada2 segfault in 2018.2 and 2017.12 (Mac OS X 10.13)

I’ve installed Qiime2 2018.2 (2018.2.0, with dada2 version 2018.2.0) in its own conda environment following the official instructions. I am getting a segfault when Qiime tries to load the dada2 R package. I came across the problem while trying to run qiime dada2 denoise-paired, but all I need to do to trigger the error is activate the conda environment, open an R session, and execute library(dada2). The error message is:

Loading required package: Rcpp

 *** caught segfault ***
address 0x1310, cause 'memory not mapped'

Traceback:
 1: dyn.load(file, DLLpath = DLLpath, ...)
 2: library.dynam(lib, package, package.lib)
 3: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
 4: asNamespace(ns)
 5: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc,     .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
 6: loadNamespace(package, lib.loc)
 7: doTryCatch(return(expr), name, parentenv, handler)
 8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 9: tryCatchList(expr, classes, parentenv, handlers)
10: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
11: library(dada2)

So it just seems to be a matter of getting this library to work within that environment.

A few notes:

  • I can load dada2 from an R session from my global environment without a problem (that is, without activating any conda environment)
  • I can load dada2 fine within an environment with Qiime2 2017.11.0 (dada2 2017.11.0) but not 2017.12.1 (dada2 2017.12.1).
  • In this thread it is recommended to reinstall dada2 using CDPATH= R -e 'source("https://bioconductor.org/biocLite.R"); biocLite("dada2")'. When I try that, I get the error ERROR: failed to lock directory ‘/Users/greg/Library/R/3.4/library’ for modifying, Try removing ‘/Users/greg/Library/R/3.4/library/00LOCK-dada2’. Which, to me, makes it seem like it’s trying to install in my global environment…When I remove that directory and run the command, it builds dada2 but then gives me the segfault error again when it tries to install it. Furthermore, dada2 then fails to load in my global environment (but works again when I reinstall it outside the conda environment).

I am running Mac OS X High Sierra 10.13.3.

I’m aware of several previous related posts (DADA2 (2017-12) segfault, memory not mapped error and DADA2: error caught segfault) where it appears that a patch has been made to 2017.12, but I get the same segfault when I install 2017.12 (version 2017.12.1) in its own conda environment. I thought I would start a new post, since those threads seem to have been closed.

Hi @Gregory_P,

Thank you for your notes, great job exploring the situation!

I think what is probably happening is you have an existing R installation with the same DADA 2 version:

We used to fix that with an .Rprofile file in your home directory, but we have a solution now which I think you'll like better:

Since you have been debugging the situation, let's go ahead and wipe the environment and start fresh:

conda env remove -n qiime2-2018.2  # change the name if you used a different one

That should remove your QIIME 2 environment. Then install using the normal instructions once more.

You should then activate your environment:

source activate qiime2-2018.2

Now our goal is to edit a file in <conda environment path>/lib/R/etc/Renviron. This command block will figure out what path that is, and then delete a line (the one that sets R_LIBS_USER) which is causing your QIIME 2 R to load packages from your system's R:

_renv=$(which qiime | sed 's/bin\/qiime/lib\/R\/etc\/Renviron/'); # find the file
[[ -f $_renv ]] && sed -i '/R_LIBS_USER/d' $_renv  # delete the line (if it exists)

Once you run that you should stop seeing the segfault!

Let me know how it goes.

Thanks @ebolyen, after I deleted the line containing R_LIBS_USER, I could load the dada2 package without problems! The sed command to delete that line did not work on my Mac but I just deleted it by hand. There may be some issues with different versions of sed. The sed error was:

sed: 1: "/Users/greg/miniconda3/ ...": extra characters at the end of g command

1 Like

Shucks. I'll have to do some more testing. Thanks for trying it out, and glad you got it working!

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