amices / mice

Multivariate Imputation by Chained Equations
https://amices.org/mice/
GNU General Public License v2.0
447 stars 108 forks source link

Installing mice fails in Docker rocker/r-ver:4.3.1 #579

Closed chStaiger closed 1 year ago

chStaiger commented 1 year ago

Describe the bug I am installing mice in Docker rocker/r-ver:4.3.1:

Mice depends on Rstan. When installing this package it stalls at this error message:

> install.packages('rstan')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://packagemanager.posit.co/cran/latest/src/contrib/rstan_2.21.8.tar.gz'
Content type 'binary/octet-stream' length 1180752 bytes (1.1 MB)
==================================================
downloaded 1.1 MB

* installing *source* package ‘rstan’ ...
** package ‘rstan’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’
using C++14
g++ -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I/usr/local/include    -fPIC  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c Module.cpp -o Module.o
g++ -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I/usr/local/include    -fPIC  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c chains.cpp -o chains.o
g++ -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"." -DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -D_REENTRANT -DSTAN_THREADS   -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppEigen/include' -I'/usr/local/lib/R/site-library/BH/include' -I'/usr/local/lib/R/site-library/StanHeaders/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -I/usr/local/include    -fPIC  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c grammar_inst.cpp -o grammar_inst.o
In file included from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/yield_k.hpp:23,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/spinlock.hpp:42,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from /usr/local/lib/R/site-library/BH/include/boost/smart_ptr/shared_ptr.hpp:29,
                 from /usr/local/lib/R/site-library/BH/include/boost/shared_ptr.hpp:17,
                 from /usr/local/lib/R/site-library/BH/include/boost/spirit/home/qi/string/symbols.hpp:30,
                 from /usr/local/lib/R/site-library/BH/include/boost/spirit/home/qi/string.hpp:15,
                 from /usr/local/lib/R/site-library/BH/include/boost/spirit/home/qi.hpp:28,
                 from /usr/local/lib/R/site-library/BH/include/boost/spirit/include/qi.hpp:16,
                 from ./stan/lang/grammars/bare_type_grammar.hpp:4,
                 from ./stan/lang/grammars/bare_type_grammar_def.hpp:5,
                 from grammar_inst.cpp:1:
/usr/local/lib/R/site-library/BH/include/boost/config/pragma_message.hpp:24:34: note: ‘#pragma message: This header is deprecated. Use <boost/phoenix/core.hpp> instead.’
   24 | # define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x)))
      |                                  ^~~~~~~
/usr/local/lib/R/site-library/BH/include/boost/config/pragma_message.hpp:24:34: note: in definition of macro ‘BOOST_PRAGMA_MESSAGE’
   24 | # define BOOST_PRAGMA_MESSAGE(x) _Pragma(BOOST_STRINGIZE(message(x)))
      |                                  ^~~~~~~
/usr/local/lib/R/site-library/BH/include/boost/spirit/include/phoenix_core.hpp:12:1: note: in expansion of macro ‘BOOST_HEADER_DEPRECATED’
   12 | BOOST_HEADER_DEPRECATED("<boost/phoenix/core.hpp>")
      | ^~~~~~~~~~~~~~~~~~~~~~~

To Reproduce You can use the following Dockerfile:

FROM rocker/r-ver:4.3.1

ARG R_VERSION=4.3.1
ARG OS_IDENTIFIER=ubuntu-2004

RUN R -e "install.packages('rstan')"
CMD ["bash"]
stefvanbuuren commented 1 year ago

I was able to build it. I saw the same notes, but then it went on.

Building takes long. rstan is a big beast and installs lots of dependencies. We only use a relatively simple function stan::Rhat() from it. Are you suggesting we consider removing it?

chStaiger commented 1 year ago

I gave it another try. But still no success with the installation. Next to the warnings, there are also some errors:

ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/usr/local/lib/R/site-library/lme4’
ERROR: dependency ‘lme4’ is not available for package ‘jomo’
* removing ‘/usr/local/lib/R/site-library/jomo’
ERROR: dependencies ‘jomo’, ‘haven’ are not available for package ‘mitml’
* removing ‘/usr/local/lib/R/site-library/mitml’
ERROR: dependency ‘mitml’ is not available for package ‘mice’
* removing ‘/usr/local/lib/R/site-library/mice’
ERROR: dependency ‘mice’ is not available for package ‘miceadds’
* removing ‘/usr/local/lib/R/site-library/miceadds’
stefvanbuuren commented 1 year ago

The problem is with two R packages: building nloptr requires the cmake library and building haven requires the zlib1g-dev linux library. I composed a Dockerfile as

FROM rocker/r-ver:4.3.1
ARG R_VERSION=4.3.1
ARG OS_IDENTIFIER=ubuntu-2004

# nloptr needs cmake
# haven needs zlib1g-dev
RUN apt update && \
    apt -y install cmake && \
    apt -y install zlib1g-dev

RUN echo 'options(repos = c(CRAN = "https://cloud.r-project.org"))' >>"${R_HOME}/etc/Rprofile.site"
RUN R -e "install.packages('remotes')"
RUN R -e "remotes::install_github('amices/mice')"

CMD ["bash"]

Please try it. If all is well, it should install around (or exactly!) 100 R packages, including the dev version of mice:

         /usr/local/lib/R/library      /usr/local/lib/R/site-library 
                           29                            71 
> packageVersion("mice")
[1] ‘3.16.4’
chStaiger commented 1 year ago

Many many thanks! It works!