Rstanをソースからインストール(オフラインで)

  • miniCRANを使えばオフラインインストールは簡単らしい。→うまくかない。

https://cran.r-project.org/web/packages/miniCRAN/vignettes/miniCRAN-introduction.html
https://blog.recyclebin.jp/archives/4587

install.packages("devtools")
https://stackoverflow.com/questions/45318188/getting-error-in-function-igraph-write-graph-graphml-while-installing-igrap

  • miniCRANパッケージのインストール
 install.packages("miniCRAN") 
  • そこで、以下根性で一つ一つ(ポイントはR程度の古い版のpackageをひたすら使うことR3.0.2だと2012年くらい)
  • ソースを集める
 wget https://cran.r-project.org/src/contrib/rstan_2.17.3.tar.gz
wget https://cran.r-project.org/src/contrib/ggplot2_2.2.1.tar.gz
wget https://cran.r-project.org/src/contrib/StanHeaders_2.17.2.tar.gz
wget https://cran.r-project.org/src/contrib/inline_0.3.14.tar.gz
wget https://cran.r-project.org/src/contrib/gridExtra_2.3.tar.gz
wget https://cran.r-project.org/src/contrib/Rcpp_0.12.15.tar.gz
wget https://cran.r-project.org/src/contrib/gtable_0.2.0.tar.gz
    • Rのバージョンの問題で最新なのはだめなので(R3.0.2)、古いバージョンをダウンロード
wget https://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_0.9.3.1.tar.gz
    • ggplot用のライブラリのソースを取得
  wget https://cran.r-project.org/src/contrib/digest_0.6.15.tar.gz
  # wget https://cran.r-project.org/src/contrib/plyr_1.8.4.tar.gz
  #  wget https://cran.r-project.org/src/contrib/reshape2_1.4.3.tar.gz
  #  wget https://cran.r-project.org/src/contrib/scales_0.5.0.tar.gz
  # R3,0.2 用に古いバージョンが必要
  wget https://cran.r-project.org/src/contrib/Archive/plyr/plyr_1.7.1.tar.gz
 wget https://cran.r-project.org/src/contrib/Archive/reshape2/reshape2_1.2.1.tar.gz
 wget https://cran.r-project.org/src/contrib/stringr_1.2.0.tar.gz
 wget http://www.mini.pw.edu.pl/~gagolews/stringi/icudt55l.zip
wget https://cran.r-project.org/src/contrib/magrittr_1.5.tar.gz
 wget https://cran.r-project.org/web/packages/magrittr/index.html
  wget https://cran.r-project.org/src/contrib/magrittr_1.5.tar.gz

   wget https://cran.r-project.org/src/contrib/RColorBrewer_1.1-2.tar.gz
    wget https://cran.r-project.org/src/contrib/dichromat_2.0-0.tar.gz
    wget https://cran.r-project.org/src/contrib/munsell_0.4.3.tar.gz
    wget https://cran.r-project.org/src/contrib/labeling_0.3.tar.gz
    wget https://cran.r-project.org/src/contrib/R6_2.2.2.tar.gz
wget https://cran.r-project.org/src/contrib/viridisLite_0.3.0.tar.gz
 wget https://cran.r-project.org/src/contrib/Archive/digest/digest_0.6.1.tar.gz
  • ソースを送り込む
   scp ggplot*.tar.gz  xxx@yyy:
 scp  ggplot*.tar.gz  xxx@yy:
    scp  ggplot*.tar.gz  xxx@yy:
    scp  Stan*.tar.gz  xxx@yy:
    scp  inline*.tar.gz  xxx@yy:
    scp  gridExtra*.tar.gz  xxx@yy:
   scp  gRcpp*.tar.gz  xxx@yy:
   scp  Rcpp*.tar.gz  xxx@yy:
   scp  gtable*.tar.gz  xxx@yy:
  scp  stringr*.tar.gz xxx@yy:
   scp stringi* xxx@yy:
  scp icudt55l.zip* xxx@yy:
 scp  magrittr_1.5.tar.gz  xxx@yy;
scp  reshape2_1.2.1.tar.gz xxx@yy:
scp  stringer*.tar.gz xxx@yy:
scp  stringr*.tar.gz xxx@yy:
scp  stringr*.tar.gz xxx@yy:
scp  stringi*.tar.gz xxx@yy:
scp  icudt551.zip xxx@yy:
scp  icudt55l.zip xxx@yy:
scp  icudt55l.zip xxx@yy:
scp  magrittr_1.5.tar.gz xxx@yy:
scp  RColorBrewer.tar.gz xxx@yy:
scp  RColorBrewer*.tar.gz xxx@yy:
scp  dichromat*.tar.gz xxx@yy:
scp  munsell*.tar.gz xxx@yy:
scp  labeling*.tar.gz xxx@yy:
scp  Rcpp*.tar.gz xxx@yy:
scp  R6*.tar.gz xxx@yy:
scp  viridisLite*.tar.gz xxx@yy:
scp  dichromat*.tar.gz xxx@yy:
scp  colorspace*.tar.gz xxx@yy:
scp  digest*.tar.gz xxx@yy:
scp  digest*.tar.gz xxx@yy:


ERROR: dependency ‘gtable’ is not available for package ‘gridExtra’
‘digest’, ‘gtable’, ‘plyr’, ‘reshape2’, ‘scales’

    • gplot2関連
 scp  dige*.tar.gz   xxx@yyy:
   scp  plyr*.tar.gz   xxx@yyy:
    scp  reshape2*.tar.gz   xxx@yyy:
    scp  scales*.tar.gz  xxx@yyy:
  • リモートのRの画面で
 install.packages("inline_0.3.14.tar.gz",repos=NULL,type="source")
install.packages("StanHeaders_2.17.2.tar.gz",repos=NULL,type="source")
install.packages("Rcpp_0.12.15.tar.gz",repos=NULL,type="source")
install.packages("Rcpp_0.12.15.tar.gz",repos=NULL,type="source")
install.packages("gtable_0.2.0.tar.gz", repos = NULL, type = "source")
install.packages("gridExtra_2.3.tar.gz", repos = NULL, type = "source")

ggplotは古い版をつかっている

install.packages("plyr_1.7.1.tar.gz", repos = NULL, type = "source")
 install.packages("stringi_1.1.6.tar.gz", repos = NULL, type = "source")
 install.packages("stringi_1.1.6.tar.gz", repos = NULL, type = "source",configure.vars="ICUDT_DIR=[dir]")
install.packages("magrittr_1.5.tar.gz", repos = NULL, type = "source")
install.packages("stringr_1.2.0.tar.gz", repos = NULL, type = "source")
install.packages("reshape2_1.2.1.tar.gz", repos = NULL, type = "source")
install.packages("gtable_0.2.0.tar.gz", repos = NULL, type = "source")
install.packages("RColorBrewer_1.1-2.tar.gz", repos = NULL, type = "source")
install.packages("dichromat_2.0-0.tar.gz ", repos = NULL, type = "source")
install.packages("colorspace_1.3-2.tar.gz", repos = NULL, type = "source")
 install.packages("munsell_0.4.3.tar.gz", repos = NULL, type = "source")
install.packages("labeling_0.3.tar.gz", repos = NULL, type = "source")
install.packages("R6_2.2.2.tar.gz", repos = NULL, type = "source")
 install.packages("viridisLite_0.3.0.tar.gz", repos = NULL, type = "source")
 install.packages("scales_0.5.0.tar.gz", repos = NULL, type = "source")
install.packages("digest_0.6.1.tar.gz", repos = NULL, type = "source")
#ggplot2.00系ではうまくいかないのでggplot1.00系へ それにともないgrstan2.8.2系
install.packages("proto_1.0.0.tar.gz", repos = NULL, type = "source")

 install.packages("BH_1.65.0-1.tar.gz", repos = NULL, type = "source")

 install.packages("Rcpp_0.10.2.tar.gz", repos = NULL, type = "source",INSTALL_opts = c('--no-lock'))
 install.packages("RcppEigen_0.3.3.4.0.tar.gz", repos = NULL, type = "source")
install.packages("Rcpp", dependencies=TRUE, INSTALL_opts = c('--no-lock'))
 install.packages("Rcpp_0.9.6.tar.gz", repos = NULL, type = "source",INSTALL_opts = c('--no-lock'))

 install.packages("rstan_2.8.2.tar.gz", repos = NULL, type = "source")

stringi が icudt55l.zip を求めるので、それをアップロードし、ディレクトリを伝える必要がある。

checking whether we can fetch icudt... downloading the ICU data library (icudt)
output path: icu55/data/icudt55l.zip
Error in download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb"): unsupported URL scheme

trying URL 'http://www.mini.pw.edu.pl/~gagolews/stringi/icudt55l.zip'
Error in download.file(paste(href, fname, sep = ""), icudtzipfname, mode = "wb"): cannot open URL 'http://www.mini.pw.edu.pl/~gagolews/stringi/icudt55l.zip'

trying URL 'http://www.ibspan.waw.pl/~gagolews/stringi/icudt55l.zip'

    • gplotの依存関係がわからない場合は、ソース内のdiscription ファイルを確認
Package: ggplot2
Version: 2.0.0
Authors@R: c(
    person("Hadley", "Wickham", , "hadley@rstudio.com", c("aut", "cre")),
    person("Winston", "Chang", , "winston@rstudio.com", "aut"),
    person("RStudio", role = "cph")
    )
Title: An Implementation of the Grammar of Graphics
Description: An implementation of the grammar of graphics in R. It combines the
    advantages of both base and lattice graphics: conditioning and shared axes
    are handled automatically, and you can still build up a plot step by step
    from multiple data sources. It also implements a sophisticated
    multidimensional conditioning system and a consistent interface to map
    data to aesthetic attributes. See http://ggplot2.org for more information,
    documentation and examples.
Depends: R (>= 2.14)
Imports: digest, grid, gtable (>= 0.1.1), MASS, plyr (>= 1.7.1),
        reshape2, scales (>= 0.3.0), stats

install.packages("stringi", configure.args="--disable-pkg-config")


> install.packages("scales_0.5.0.tar.gz", repos = NULL, type = "source")
Installing package into ‘/home1/h-wata/R/x86_64-unknown-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
ERROR: dependencies ‘RColorBrewer’, ‘dichromat’, ‘munsell’, ‘labeling’, ‘R6’, ‘viridisLite’ are not available for package ‘scales’

Imports: methods, stats4, inline, gridExtra (>= 2.0.0), Rcpp (>=
0.11.0)
2 or later, as is the rest of Rcpp.
License: GPL (>= 2)
Depends: Rcpp (>= 0.9.6), Matrix (>= 1.0-1), R(>= 2.14.0)
LazyLoad: yes
LinkingTo: Rcpp

icpc -I/ap1/r/3.0.2/lib64/R/include -DNDEBUG -I/usr/local/include -I"/home1/h-wata/R/x86_64-unknown-linux-gnu-library/3.0/Rcpp/include" -I../inst/include -fpic -O3 -ipo -openmp -xHost -c fastLm.cpp -o fastLm.o


install.packages("RcppEigen_0.3.3.4.0.tar.gz", repos = NULL, type = "source")



../inst/include/Eigen/src/Jacobi/Jacobi.h(456): error: expression must have a constant value


c++ -I/ap1/r/3.0.2/lib64/R/include -DNDEBUG -I/usr/local/include -I"/home1/h-wata/R/x86_64-unknown-linux-gnu-library/3.0/Rcpp/include" -I../inst/include -fpic -O3 -openmp -c fastLm.cpp -o fastLm.o

https://github.com/stan-dev/rstan/wiki/Installing-RStan-on-Mac-or-Linux#configuration
https://stackoverflow.com/questions/1616983/building-r-packages-using-alternate-gcc
インテルコンパイラが悪さしていて、さらに、xHost フラグがわるさしてる
https://stackoverflow.com/questions/43597632/understanding-the-contents-of-the-makevars-file-in-r-macros-variables-r-ma

CRPP0.10.0 じゃないとバグがでるらしい。RCPPはインテルコンパイラ
https://support.bioconductor.org/p/49516/

install.packages("Rcpp_0.3.1.tar.gz", repos = NULL, type = "source",INSTALL_opts = c('--no-lock'))
 
バージョンさげると… インテルコンパイラに戻す必要あり
Error: package ‘Rcpp’ 0.10.0 was found, but >= 0.12.0 is required by ‘rstan’

boostがおかしいとかいわれる
https://github.com/stan-dev/rstan/issues/447#issuecomment-325172186 を参考に

/home1/h-wata/R/x86_64-unknown-linux-gnu-library/3.0/BH/include/boost/phoenix/core/limits.hpp(44): warning #47: incompatible redefinition of macro "BOOST_PHOENIX_NO_VARIADIC_EXPRESSION"
# define BOOST_PHOENIX_NO_VARIADIC_EXPRESSION
out further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
#warning \
^
make: *** [lang__grammars__term_grammar_inst.o] Error 2
https://github.com/stan-dev/rstan/issues/210


NeedsCompilation: yes
Imports: methods, stats4, inline, gridExtra (>= 2.0.0), Rcpp (>=
0.11.0)
Depends: R (>= 3.0.2), ggplot2 (>= 1.0.0)
LinkingTo: Rcpp, RcppEigen, BH (>= 1.58), StanHeaders (>= 2.8.0)
Suggests: RUnit, RcppEigen, BH (>= 1.58), StanHeaders (>= 2.8.0),


> install.packages("StanHeaders_2.8.0.tar.gz", repos = NULL, type = "source")

compilation aborted for lang__ast_def.cpp (code 2)
make: *** [lang__ast_def.o] Error 2