conda-forge / r-rstan-feedstock

A conda-smithy repository for r-rstan.
BSD 3-Clause "New" or "Revised" License
1 stars 9 forks source link

stanheaders and bh packages need to be specified in win64 #13

Open wetlandscapes opened 4 years ago

wetlandscapes commented 4 years ago

Issue: I'm using a Windows 10 machine with a "self-contained" toolchain (rather than a global install of Rtools) following the instructions here: https://github.com/ContinuumIO/anaconda-issues/wiki/Install-R-Packages. That has been the only way I've been able to get rstan to work in a conda environment. However, what I've noticed are:

  1. The default version of r-stanheaders installed is ahead of r-rstan,
  2. The default version of r-bh installed does not match the version of r-rstan.

The way I've gotten around these issues is to specify a version of r-rstan, r-stanheaders, and r-bh that all seem to play nice together, but that counter to the intent of conda, since it should "just work" when telling conda to install rstan.

Below are the instructions I follow (I tried to make it as minimal a reprex as possible). Note that if I specify r-rstan=2.17, r-stanheaders=2.17, and r-bh=1.66 in my .yml file then everything works fine.


Reprex/instructions:

1. Create an `tmp.yml` file in some working directory: ```yml name: tmp channels: - conda-forge - r - defaults dependencies: #Some useful instructions for installing R packages via conda on Windows: # https://github.com/ContinuumIO/anaconda-issues/wiki/Install-R-Packages # Toolchain (what Rtools usually takes care of) - m2w64-toolchain - m2-make - m2-sed - m2-zip - m2-gzip - m2-tar - m2-texinfo - m2-coreutils #R stuff - r-base - r-rstan - r-stanheaders - r-bh ``` 2. Create the environment: ``` conda env create -f tmp.yml ``` 3. Navigate to the environment's `Library` directory and add a `tmp` folder. This is, for some reason, necessary for the toolchain (see the ContinuumIO link). For example, on my computer, this would result in the following folder structure: ``` C:\Users\Trader\miniconda3\envs\tmp\Library\tmp ``` 4. Activate the environment: ``` conda activate tmp ``` 5. Create a `.Renviron` file. For some reason, I can't change the system variables in an R session (I have been able to do this from RStudio, but I'm trying to reduce the overhead of this example). ```r R_HOME=C:/Users/Trader/miniconda3/envs/tmp/lib/R R_LIBS_USER=C:/Users/Trader/miniconda3/envs/tmp/R/library R_USER=C:/Users/Trader/miniconda3/envs/tmp ``` 6. Test that the installation worked properly, start up R: ``` R.exe ``` 7. Inside of R, test that the toolchain works: ```r pkgbuild::has_build_tools(debug = TRUE) #Should return TRUE, and does for me. ``` 8. Test that `{rstan}` works. This breaks when I try to fit the model. ```r library(rstan) model_text <- "data { int J; // number of schools real y[J]; // estimated treatment effects real sigma[J]; // standard error of effect estimates } parameters { real mu; // population treatment effect real tau; // standard deviation in treatment effects vector[J] eta; // unscaled deviation from mu by school } transformed parameters { vector[J] theta = mu + tau * eta; // school treatment effects } model { target += normal_lpdf(eta | 0, 1); // prior log-density target += normal_lpdf(y | theta, sigma); // log-likelihood }" schools_dat <- list(J = 8, y = c(28, 8, -3, 7, -1, 1, 18, 12), sigma = c(15, 10, 16, 11, 9, 11, 10, 18)) fit <- stan(model_code = model_text, data = schools_dat) ``` The error from the last line of code: ```r Error in stan_model(file, model_name = model_name, model_code = model_code, : StanHeaders version is ahead of rstan version; see https://github.com/stan-dev/rstan/wiki/RStan-Transition-Periods ```


Environment (conda list):

``` $ conda list # Name Version Build Channel _r-mutex 1.0.1 anacondar_1 conda-forge intel-openmp 2020.0 166 libblas 3.8.0 15_mkl conda-forge liblapack 3.8.0 15_mkl conda-forge m2-bash 4.3.042 5 m2-coreutils 8.25 102 m2-db 5.3.28 3 m2-gcc-libs 5.3.0 4 m2-gdbm 1.11 4 m2-gmp 6.1.0 3 m2-gzip 1.7 2 m2-info 6.0 2 m2-less 481 2 m2-libbz2 1.0.6 3 m2-libcrypt 1.3 2 m2-libdb 5.3.28 3 m2-libgdbm 1.11 4 m2-libiconv 1.14 3 m2-libintl 0.19.7 4 m2-libpcre 8.38 2 m2-make 4.1 5 m2-msys2-runtime 2.5.0.17080.65c939c 3 m2-ncurses 6.0.20160220 2 m2-perl 5.22.1 2 m2-sed 4.2.2 3 m2-tar 1.28 4 m2-texinfo 6.0 2 m2-zip 3.0 2 m2w64-binutils 2.25.1 5 m2w64-bwidget 1.9.10 2 m2w64-bzip2 1.0.6 6 m2w64-crt-git 5.0.0.4636.2595836 2 m2w64-expat 2.1.1 2 m2w64-fftw 3.3.4 6 m2w64-flac 1.3.1 3 m2w64-gcc 5.3.0 6 m2w64-gcc-ada 5.3.0 6 m2w64-gcc-fortran 5.3.0 6 m2w64-gcc-libgfortran 5.3.0 6 m2w64-gcc-libs 5.3.0 7 m2w64-gcc-libs-core 5.3.0 7 m2w64-gcc-objc 5.3.0 6 m2w64-gettext 0.19.7 2 m2w64-gmp 6.1.0 2 m2w64-gsl 2.1 2 m2w64-headers-git 5.0.0.4636.c0ad18a 2 m2w64-isl 0.16.1 2 m2w64-libiconv 1.14 6 m2w64-libjpeg-turbo 1.4.2 3 m2w64-libmangle-git 5.0.0.4509.2e5a9a2 2 m2w64-libogg 1.3.2 3 m2w64-libpng 1.6.21 2 m2w64-libsndfile 1.0.26 2 m2w64-libtiff 4.0.6 2 m2w64-libvorbis 1.3.5 2 m2w64-libwinpthread-git 5.0.0.4634.697f757 2 m2w64-libxml2 2.9.3 4 m2w64-make 4.1.2351.a80a8b8 2 m2w64-mpc 1.0.3 3 m2w64-mpfr 3.1.4 4 m2w64-openblas 0.2.19 1 m2w64-pcre 8.38 2 m2w64-pkg-config 0.29.1 2 m2w64-speex 1.2rc2 3 m2w64-speexdsp 1.2rc3 3 m2w64-tcl 8.6.5 3 m2w64-tk 8.6.5 3 m2w64-tktable 2.10 5 m2w64-toolchain 5.3.0 7 m2w64-tools-git 5.0.0.4592.90b8472 2 m2w64-windows-default-manifest 6.4 3 m2w64-wineditline 2.101 5 m2w64-winpthreads-git 5.0.0.4634.697f757 2 m2w64-xz 5.2.2 2 m2w64-zlib 1.2.8 10 mkl 2020.0 166 msys2-conda-epoch 20160418 1 r-assertthat 0.2.1 r35h6115d3f_1 conda-forge r-backports 1.1.6 r35hda5aaf8_1 conda-forge r-base 3.5.1 h0c8e037_1012 conda-forge r-bh 1.72.0_3 r35h6115d3f_0 conda-forge r-callr 3.4.3 r35h6115d3f_0 conda-forge r-cli 2.0.2 r35h6115d3f_0 conda-forge r-colorspace 1.4_1 r35hda5aaf8_1 conda-forge r-crayon 1.3.4 r35h6115d3f_1002 conda-forge r-desc 1.2.0 r35h6115d3f_1002 conda-forge r-digest 0.6.25 r35h796a38f_1 conda-forge r-ellipsis 0.3.0 r35hda5aaf8_0 conda-forge r-evaluate 0.14 r35h6115d3f_1 conda-forge r-fansi 0.4.1 r35hda5aaf8_0 conda-forge r-farver 2.0.3 r35h796a38f_0 conda-forge r-ggplot2 3.3.0 r35h6115d3f_0 conda-forge r-glue 1.4.0 r35hda5aaf8_0 conda-forge r-gridextra 2.3 r35h6115d3f_1002 conda-forge r-gtable 0.3.0 r35h6115d3f_2 conda-forge r-inline 0.3.15 r35h6115d3f_1001 conda-forge r-isoband 0.2.1 r35h796a38f_0 conda-forge r-labeling 0.3 r35h6115d3f_1002 conda-forge r-lattice 0.20_41 r35hda5aaf8_1 conda-forge r-lifecycle 0.2.0 r35h6115d3f_0 conda-forge r-magrittr 1.5 r35h6115d3f_1002 conda-forge r-mass 7.3_51.6 r35hda5aaf8_1 conda-forge r-matrix 1.2_18 r35h0adb578_2 conda-forge r-mgcv 1.8_31 r35h0adb578_0 conda-forge r-munsell 0.5.0 r35h6115d3f_1002 conda-forge r-nlme 3.1_147 r35h17ddedb_0 conda-forge r-pillar 1.4.3 r35h6115d3f_0 conda-forge r-pkgbuild 1.0.7 r35h6115d3f_0 conda-forge r-pkgconfig 2.0.3 r35h6115d3f_0 conda-forge r-pkgload 1.0.2 r35h796a38f_1001 conda-forge r-praise 1.0.0 r35h6115d3f_1003 conda-forge r-prettyunits 1.1.1 r35h6115d3f_0 conda-forge r-processx 3.4.2 r35hda5aaf8_0 conda-forge r-ps 1.3.2 r35hda5aaf8_0 conda-forge r-r6 2.4.1 r35h6115d3f_0 conda-forge r-rcolorbrewer 1.1_2 r35h6115d3f_1002 conda-forge r-rcpp 1.0.4.6 r35h796a38f_0 conda-forge r-rcppeigen 0.3.3.7.0 r35h796a38f_0 conda-forge r-rlang 0.4.5 r35hda5aaf8_2 conda-forge r-rprojroot 1.3_2 r35h6115d3f_1002 conda-forge r-rstan 2.17.3 r351h6115d3f_2 conda-forge r-rstudioapi 0.11 r35h6115d3f_0 conda-forge r-scales 1.1.0 r35h6115d3f_0 conda-forge r-stanheaders 2.21.0_1 r35h5b3a9a7_0 conda-forge r-testthat 2.3.2 r35h796a38f_0 conda-forge r-tibble 3.0.1 r35hda5aaf8_0 conda-forge r-utf8 1.1.4 r35hda5aaf8_1002 conda-forge r-vctrs 0.2.4 r35hda5aaf8_0 conda-forge r-viridislite 0.3.0 r35h6115d3f_1002 conda-forge r-withr 2.2.0 r35h6115d3f_0 conda-forge r-zeallot 0.1.0 r35h6115d3f_1001 conda-forge ```


Details about conda and system ( conda info ):

``` $ conda info active environment : tmp active env location : C:\Users\Trader\miniconda3\envs\tmp shell level : 2 user config file : C:\Users\Trader\.condarc populated config files : C:\Users\Trader\.condarc conda version : 4.8.3 conda-build version : not installed python version : 3.7.6.final.0 virtual packages : __cuda=10.1 base environment : C:\Users\Trader\miniconda3 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:\Users\Trader\miniconda3\pkgs C:\Users\Trader\.conda\pkgs C:\Users\Trader\AppData\Local\conda\conda\pkgs envs directories : C:\Users\Trader\miniconda3\envs C:\Users\Trader\.conda\envs C:\Users\Trader\AppData\Local\conda\conda\envs platform : win-64 user-agent : conda/4.8.3 requests/2.23.0 CPython/3.7.6 Windows/10 Windows/10.0.18362 administrator : False netrc file : None offline mode : False ```

I'm pretty new to conda, but if there is some way I can help, please let me know. I very much appreciate the effort you all have put into developing this package.