knncolle / BiocNeighbors

Clone of the Bioconductor repository for the BiocNeighbors package.
https://bioconductor.org/packages/devel/bioc/html/BiocNeighbors.html
6 stars 11 forks source link

Install issue with RcppAnnoy 0.0.17 #17

Closed scottgigante closed 3 years ago

scottgigante commented 3 years ago

Hitting an installation error on Debian Stretch.

> BiocManager::install("BiocNeighbors")
Bioconductor version 3.10 (BiocManager 1.30.10), R 3.6.3 (2020-02-29)
Installing package(s) 'BiocNeighbors'
trying URL 'https://bioconductor.org/packages/3.10/bioc/src/contrib/BiocNeighbors_1.4.2.tar.gz'
Content type 'application/x-gzip' length 902918 bytes (881 KB)
==================================================
downloaded 881 KB

* installing *source* package ‘BiocNeighbors’ ...
** using staged installation
** libs
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppAnnoy/include" -I"/usr/local/lib/R/site-library/RcppHNSW/include"   -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.6.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppAnnoy/include" -I"/usr/local/lib/R/site-library/RcppHNSW/include"   -fpic  -g -O2 -fdebug-prefix-map=/home/jranke/git/r-backports/stretch/r-base-3.6.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c annoy.cpp -o annoy.o
In file included from annoy.cpp:1:0:
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:0,
                 from annoy.cpp:1:
/usr/local/lib/R/site-library/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<Distance>::Annoy(int, const string&, double)’:
annoy.cpp:7:9: error: request for member ‘load’ in ‘((Annoy<Distance>*)this)->Annoy<Distance>::obj’, which is of non-class type ‘Annoy<Distance>::_index {aka int}’
     obj.load(fname.c_str());
         ^~~~
annoy.cpp: In member function ‘MatDim_t Annoy<Distance>::get_nobs() const’:
annoy.cpp:16:16: error: request for member ‘get_n_items’ in ‘((const Annoy<Distance>*)this)->Annoy<Distance>::obj’, which is of non-class type ‘const _index {aka const int}’
     return obj.get_n_items();
                ^~~~~~~~~~~
annoy.cpp: In member function ‘void Annoy<Distance>::find_nearest_neighbors(CellIndex_t, NumNeighbors_t, bool, bool)’:
annoy.cpp:44:9: error: request for member ‘get_nns_by_item’ in ‘((Annoy<Distance>*)this)->Annoy<Distance>::obj’, which is of non-class type ‘Annoy<Distance>::_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<Distance>::find_nearest_neighbors(const double*, NumNeighbors_t, bool, bool)’:
annoy.cpp:86:9: error: request for member ‘get_nns_by_vector’ in ‘((Annoy<Distance>*)this)->Annoy<Distance>::obj’, which is of non-class type ‘Annoy<Distance>::_index {aka int}’
     obj.get_nns_by_vector(holding.data(), K, get_search_k(K), &kept_idx, dptr);
         ^~~~~~~~~~~~~~~~~
In file included from annoy.cpp:97:0:
build_annoy.cpp: In instantiation of ‘Rcpp::RObject build_annoy_internal(Rcpp::NumericMatrix, int, const string&) [with Distance = Manhattan; Rcpp::RObject = Rcpp::RObject_Impl<Rcpp::PreserveStorage>; Rcpp::NumericMatrix = Rcpp::Matrix<14>; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
build_annoy.cpp:26:66:   required from here
build_annoy.cpp:14:13: error: request for member ‘add_item’ in ‘obj’, which is of non-class type ‘Annoy<Manhattan>::_index {aka int}’
         obj.add_item(i, tmp.data());
         ~~~~^~~~~~~~
build_annoy.cpp:17:9: error: request for member ‘build’ in ‘obj’, which is of non-class type ‘Annoy<Manhattan>::_index {aka int}’
     obj.build(Ntrees);
     ~~~~^~~~~
build_annoy.cpp:18:9: error: request for member ‘save’ in ‘obj’, which is of non-class type ‘Annoy<Manhattan>::_index {aka int}’
     obj.save(Fname.c_str());
     ~~~~^~~~
build_annoy.cpp: In instantiation of ‘Rcpp::RObject build_annoy_internal(Rcpp::NumericMatrix, int, const string&) [with Distance = Euclidean; Rcpp::RObject = Rcpp::RObject_Impl<Rcpp::PreserveStorage>; Rcpp::NumericMatrix = Rcpp::Matrix<14>; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
build_annoy.cpp:28:66:   required from here
build_annoy.cpp:14:13: error: request for member ‘add_item’ in ‘obj’, which is of non-class type ‘Annoy<Euclidean>::_index {aka int}’
         obj.add_item(i, tmp.data());
         ~~~~^~~~~~~~
build_annoy.cpp:17:9: error: request for member ‘build’ in ‘obj’, which is of non-class type ‘Annoy<Euclidean>::_index {aka int}’
     obj.build(Ntrees);
     ~~~~^~~~~
build_annoy.cpp:18:9: error: request for member ‘save’ in ‘obj’, which is of non-class type ‘Annoy<Euclidean>::_index {aka int}’
     obj.save(Fname.c_str());
     ~~~~^~~~
/usr/lib/R/etc/Makeconf:177: recipe for target 'annoy.o' failed
make: *** [annoy.o] Error 1
ERROR: compilation failed for package ‘BiocNeighbors’
* removing ‘/usr/local/lib/R/site-library/BiocNeighbors’

The downloaded source packages are in
        ‘/tmp/Rtmp56Q2DZ/downloaded_packages’
Old packages: 'processx', 'rlang'
Update all/some/none? [a/s/n]: n
Warning message:
In install.packages(...) :
  installation of package ‘BiocNeighbors’ had non-zero exit status

Session info:

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS:   /usr/lib/libblas/libblas.so.3.7.0
LAPACK: /usr/lib/lapack/liblapack.so.3.7.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] RcppAnnoy_0.0.17

loaded via a namespace (and not attached):
[1] BiocManager_1.30.10 compiler_3.6.3      tools_3.6.3
[4] Rcpp_1.0.5
LTLA commented 3 years ago

Use the latest release version (1.8.1) or devel version (1.9.2).

hsiaoyi0504 commented 3 years ago

I meet the same issue. I am able to install the devel version with devtools::install_github('LTLA/BiocNeighbors'). However, it seems to me that there is no specific tag for the latest release version. Is it available in one of the branches?

LTLA commented 3 years ago

Just to be clear: this GitHub repository is solely for the developers.

For Bioconductor packages, the official source is, as one might expect, Bioconductor itself:

https://www.bioconductor.org/packages/release/bioc/html/BiocNeighbors.html (release) https://www.bioconductor.org/packages/devel/bioc/html/BiocNeighbors.html (devel)

hsiaoyi0504 commented 3 years ago

But in this case, it seems to me that I can't directly install packages in Bioconductor 3.11 or 3.12 given I use R 3.6.

LTLA commented 3 years ago

In that case, you'd be looking at:

https://www.bioconductor.org/packages/3.10/bioc/html/BiocNeighbors.html

The problem in your case is not with BiocNeighbors per se; it's because RcppAnnoy made backwards-incompatible changes, inherited from the Annoy C++ library itself. If you want to use BioC 3.10, the real fix is get an appropriately old version of RcppAnnoy - this should be possible with something like:

devtools::install_version("RcppAnnoy", "0.0.16", repos="http://cran.us.r-project.org")

Perhaps there is some tooling that downgrades CRAN for you automatically, but I don't ever do this, so I wouldn't know.

In any case, BioC 3.11 and below are now frozen; patches are only being delivered to 3.12 or higher. So unless you have a specific need to use R <= 3.6 (e.g., to reproduce old results), I'd suggest using the latest version.

hsiaoyi0504 commented 3 years ago

@LTLA Thank you so much for the detailed explanation. I really appreciate it.

LTLA commented 3 years ago

Some closing comments:

The latest release and devel versions of BiocNeighbors will vendor the RcppAnnoy C++ headers, for reproducibility reasons as discussed in jlmelville/uwot#69. As a side effect, this means that we will not be susceptible to backward incompatibilities introduced by Annoy library updates. Won't solve the problem in this case but it'll ensure that it won't happen again in the future.

If you must continue using R 3.6.3, the BiocManager functionality linked above may be useful. In particular:

# 166 corresponds to the last day of the 3.10 release.
options(repos = c(CRAN = "https://packagemanager.rstudio.com/all/166"))
BiocManager::install("BiocNeighbors", version="3.10") # well, there's not much choice for version anyway.

This will reproduce the packages as of 28th April, see https://packagemanager.rstudio.com/client/#/repos/1/overview.

asistradition commented 3 years ago
In file included from annoy.cpp(1):
annoy.h(33): error: too few arguments for class template "AnnoyIndex"
      typedef AnnoyIndex<Index_t, Data_t, Distance, Kiss64Random> _index;
                                                                ^

compilation aborted for annoy.cpp (code 2)
make: *** [] Error 2
ERROR: compilation failed for package ‘BiocNeighbors’

Different install error associated with the same Annoy library update. Also resolved by downgrading RcppAnnoy to 0.0.16. Providing it in case anyone's searching for the same problem.