Error when installing 'BiocNeighbors'

When trying to install SingleR package:


Process failed because dependency ‘BiocNeighbors’ compilation failed. I tried to install ‘BiocNeighbors’ by itself but I get the same error (compilation failed). Other packages using biocmanager failed to install when ‘BiocNeighbors’ is a dependency.

Any help would be really appreciated!

@rklotz Could you share the error message that you get with the compilation failing for BiocNeighbors? I’m able to install both packages, but maybe there’s something different about my setup.

@dstrong Thanks for your reply. Here is the full message.


Bioconductor version 3.11 (BiocManager 1.30.10), R 4.0.0 (2020-04-24)
Installing package(s) ‘BiocNeighbors’
trying URL ‘
Content type ‘application/x-gzip’ length 907994 bytes (886 KB)

downloaded 886 KB

  • installing source package ‘BiocNeighbors’ …
    ** using staged installation
    ** libs
    /spack/apps/gcc/8.3.0/bin/g++ -std=gnu++11 -I"/spack/apps/linux-centos7-x86_64/gcc-8.3.0/r-4.0.0-jfy3icn4kexk7kyabcoxuio2iyyww3o7/rlib/R/include" -DNDEBUG -I’/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include’ -I’/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/RcppAnnoy/include’ -I’/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/RcppHNSW/include’ -I/usr/local/include -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o
    /spack/apps/gcc/8.3.0/bin/g++ -std=gnu++11 -I"/spack/apps/linux-centos7-x86_64/gcc-8.3.0/r-4.0.0-jfy3icn4kexk7kyabcoxuio2iyyww3o7/rlib/R/include" -DNDEBUG -I’/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/Rcpp/include’ -I’/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/RcppAnnoy/include’ -I’/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/RcppHNSW/include’ -I/usr/local/include -fpic -g -O2 -c annoy.cpp -o annoy.o
    In file included from annoy.cpp:1:
    annoy.h:33:63: error: wrong number of template arguments (4, should be 5)
    typedef AnnoyIndex<Index_t, Data_t, Distance, Kiss64Random> _index;
    In file included from annoy.h:17,
    from annoy.cpp:1:
    /home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/RcppAnnoy/include/annoylib.h:845:9: note: provided for ‘template<class S, class T, class Distance, class Random, class ThreadedBuildPolicy> class AnnoyIndex’
    class AnnoyIndex : public AnnoyIndexInterface<S, T,
    annoy.cpp: In constructor ‘Annoy::Annoy(int, const string&, double)’:
    annoy.cpp:7:9: error: request for member ‘load’ in ‘((Annoy)this)->Annoy::obj’, which is of non-class type ‘Annoy::_index’ {aka ‘int’}
    annoy.cpp: In member function ‘MatDim_t Annoy::get_nobs() const’:
    annoy.cpp:16:16: error: request for member ‘get_n_items’ in ‘((const Annoy
    )this)->Annoy::obj’, which is of non-class type ‘const _index’ {aka ‘const int’}
    return obj.get_n_items();
    annoy.cpp: In member function ‘void Annoy::find_nearest_neighbors(CellIndex_t, NumNeighbors_t, bool, bool)’:
    annoy.cpp:44:9: error: request for member ‘get_nns_by_item’ in ‘((Annoy)this)->Annoy::obj’, which is of non-class type ‘Annoy::_index’ {aka ‘int’}
    obj.get_nns_by_item(c, K + 1, get_search_k(K + 1), &kept_idx, dptr); // +1, as it forgets to discard ‘self’.
    annoy.cpp: In member function ‘void Annoy::find_nearest_neighbors(const double
    , NumNeighbors_t, bool, bool)’:
    annoy.cpp:86:9: error: request for member ‘get_nns_by_vector’ in ‘((Annoy*)this)->Annoy::obj’, which is of non-class type ‘Annoy::_index’ {aka ‘int’}
    obj.get_nns_by_vector(, K, get_search_k(K), &kept_idx, dptr);
    make: *** [annoy.o] Error 1
    ERROR: compilation failed for package ‘BiocNeighbors’
  • removing ‘/home1/rklotz/R/x86_64-pc-linux-gnu-library/4.0/BiocNeighbors’

The downloaded source packages are in
Installation path not writeable, unable to update packages: anytime, assertr,
backports, baguette, batchtools, bayesplot, betareg, BH, bibtex, bit64, boot,
broom, callr, car, caTools, checkpoint, chron, class, cli, clipr, cluster,
coda, codetools, coin, colorspace, colourpicker, config, conquer, corrr,
covr, cpp11, crayon, crosstalk, crul, CVXR, data.table, DBI, dbplyr, deldir,
dendextend, DescTools, devtools, dfidx, dials, DiceDesign, digest, discrim,
distributional, doParallel, dplyr, drake, DT, e1071, earth, ECOSolveR, embed,
Exact, expm, fable, fabletools, fansi, fastmap, feasts, flexmix, forcats,
foreach, foreign, Formula, furrr, future, generics, ggplot2, ggraph, ggrepel,
ggridges, gh, git2r, globals, glue, gmp, gplots, graphlayouts, hardhat, here,
hexbin, Hmisc, hms, htmlTable, htmltools, htmlwidgets, httpuv, igraph, infer,
inline, insight, inum, isoband, iterators, janitor, jsonlite, kableExtra,
KernSmooth, knitr, labeling, lava, lhs, libcoin, lifecycle, lme4, lmtest,
loo, lubridate, magrittr, maptools, MASS, Matrix, matrixStats, maxLik,
mboost, memoise, mgcv, mice, mime, mlogit, mlr, modeldata, multcomp, nlme,
NLP, nnet, openssl, openxlsx, parsnip, party, partykit, pbkrtest, pillar,
pkgbuild, plm, plotmo, plotrix, prettydoc, pROC, processx, progressr,
promises, ps, quantmod, quantreg, R6, rappdirs, raster, rasterVis, Rcpp,
RcppAnnoy, RcppArmadillo, RcppEigen, Rdpack, readr, recipes, renv, repr,
reprex, reticulate, rlang, RMariaDB, rmarkdown, Rmpfr, rms, rprojroot,
rsample, RSQLite, rstudioapi, rsvg, sampleSelection, sandwich, sass,
seriation, shiny, shinyjs, shinythemes, sjlabelled, sjmisc, slam, sp,
spacetime, SparseM, spatial, SQUAREM, stabs, StanHeaders, statmod, storr,
stringi, survival, testthat, textrecipes, themis, tibble, tidymodels,
tidypredict, tidyr, tinytex, tm, tseries, tsibble, TTR, tune, usethis, uwot,
V8, vctrs, VGAM, warp, withr, workflows, xfun, xts, zip
Warning message:
In install.packages(…) :
installation of package ‘BiocNeighbors’ had non-zero exit status

It looks like the version of package RcppAnnoy you have installed in your user directory is too new. Try downgrading that package (devtools::install_version("RcppAnnoy", version = "0.0.16")) or uninstall it from your user directory to use the older version installed in the system library. Then BiocNeighbors should install successfully. Not sure if you have other packages that depend on the newer version though.

1 Like

Thank you @dstrong I removed the 0.0.18 version and successfully installed ‘BiocNeighbors’ with ‘RcppAnnoy’ 0.0.16 from the system library. I do have ‘Seurat’ package that needs ‘RccpAnnoy’ 0.0.18. After installing ‘BiocNeighbors’ I reinstalled ‘RcppAnnoy’ v 0.0.18 and I am able to load ‘Seurat’ package.

1 Like

Okay, sounds good. If the package dependency issues become more complicated, look into creating separate environments with the renv package.

1 Like