Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makevars location is incorrect for RStudio #1

Open
KariOlson-KD opened this issue Feb 3, 2021 · 0 comments
Open

Makevars location is incorrect for RStudio #1

KariOlson-KD opened this issue Feb 3, 2021 · 0 comments

Comments

@KariOlson-KD
Copy link

I recently ran into some difficulty compiling a model in RStudio that I think believe is due to HOME being different between R command line and RStudio.

/home/rstudio/.R/Makevars is not generated during container instantiation, however /root/.R/Makevars exists. HOME in R is /root. HOME in RStudio is /home/rstudio.

I believe that running install_stan.R using command line R, is why ~/.R/Makevars file is created in /root instead of /home/rstudio.

It can be confirmed that /.R/Makevars has not been properly generated by running in Rstudio: > readLines("/.R/Makevars") Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") :
cannot open file '/home/rstudio/.R/Makevars': No such file or directory

Symptoms: Stan model compile problems that depend upon the model being compiled (some simple models compile without error but schools.stan example here does not).
Correction: generating Makevars file in /home/rstudio allows schools.stan to compile.

Specific error message for schools.stan:
Error in compileCode(f, code, language = language, verbose = verbose) :
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/Core/DenseCoeffsBase.h:55:30: warning: ignoring attributes on template argument ‘Eigen::internal::packet_traits::type’ {aka ‘__vector(2) double’} [-Wignored-attributes] 55 | >::type PacketReturnType; | ^~~~~~~~~~~~~~~~g++: fatal error: Killed signal terminated program cc1pluscompilation terminated.make: *** [/usr/local/lib/R/etc/Makeconf:181: file16f20d9e181.o] Error 1

before running Makevars script within RStudio, we are given this information about compiler setttings:

> mod <- stan_model("schools.stan", verbose=TRUE)

TRANSLATING MODEL 'schools' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model 'schools'.
COMPILING THE C++ CODE FOR MODEL 'schools' NOW.
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.6; inline: 0.3.17 
 >> setting environment variables: 
PKG_LIBS =  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb
PKG_CPPFLAGS =   -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/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src/"  -I"/usr/local/lib/R/site-library/StanHeaders/include/"  -I"/usr/local/lib/R/site-library/RcppParallel/include/"  -I"/usr/local/lib/R/site-library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 
 >> Program source :
...
make cmd is
  make -f '/usr/local/lib/R/etc/Makeconf' -f '/usr/local/lib/R/share/make/shlib.mk' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file16f20d9e181.so' OBJECTS='file16f20d9e181.o'

make would use
**g++** -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG   -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/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src/"  -I"/usr/local/lib/R/site-library/StanHeaders/include/"  -I"/usr/local/lib/R/site-library/RcppParallel/include/"  -I"/usr/local/lib/R/site-library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c file16f20d9e181.cpp -o file16f20d9e181.o
if test  "zfile16f20d9e181.o" != "z"; then \
  echo g++ -std=gnu++14 -shared -L"/usr/local/lib/R/lib" -L/usr/local/lib -o file16f20d9e181.so file16f20d9e181.o  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb  -L"/usr/local/lib/R/lib" -lR; \
  g++ -std=gnu++14 -shared -L"/usr/local/lib/R/lib" -L/usr/local/lib -o file16f20d9e181.so file16f20d9e181.o  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb  -L"/usr/local/lib/R/lib" -lR; \
fi

after adding the Makevars, it changes:

> mod <- stan_model("schools.stan", verbose=TRUE)

TRANSLATING MODEL 'schools' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model 'schools'.
COMPILING THE C++ CODE FOR MODEL 'schools' NOW.
OS: x86_64, linux-gnu; rstan: 2.21.2; Rcpp: 1.0.6; inline: 0.3.17 
 >> setting environment variables: 
PKG_LIBS =  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb
PKG_CPPFLAGS =   -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/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src/"  -I"/usr/local/lib/R/site-library/StanHeaders/include/"  -I"/usr/local/lib/R/site-library/RcppParallel/include/"  -I"/usr/local/lib/R/site-library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 
 >> Program source :
...
make cmd is
  make -f '/usr/local/lib/R/etc/Makeconf' -f '/usr/local/lib/R/share/make/shlib.mk' -f '/home/rstudio/.R/Makevars' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='file16f67e794ea.so' OBJECTS='file16f67e794ea.o'

make would use
**clang++** -std=gnu++14 -I"/usr/local/lib/R/include" -DNDEBUG   -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/RcppEigen/include/unsupported"  -I"/usr/local/lib/R/site-library/BH/include" -I"/usr/local/lib/R/site-library/StanHeaders/include/src/"  -I"/usr/local/lib/R/site-library/StanHeaders/include/"  -I"/usr/local/lib/R/site-library/RcppParallel/include/"  -I"/usr/local/lib/R/site-library/rstan/include" -DEIGEN_NO_DEBUG  -DBOOST_DISABLE_ASSERTS  -DBOOST_PENDING_INTEGER_LOG2_HPP  -DSTAN_THREADS  -DBOOST_NO_AUTO_PTR  -include '/usr/local/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fpic  -O3 -march=native -mtune=native -fPIC -c file16f67e794ea.cpp -o file16f67e794ea.o
if test  "zfile16f67e794ea.o" != "z"; then \
  echo clang++ -std=gnu++14 -shared -L"/usr/local/lib/R/lib" -L/usr/local/lib -o file16f67e794ea.so file16f67e794ea.o  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb  -L"/usr/local/lib/R/lib" -lR; \
  clang++ -std=gnu++14 -shared -L"/usr/local/lib/R/lib" -L/usr/local/lib -o file16f67e794ea.so file16f67e794ea.o  '/usr/local/lib/R/site-library/rstan/lib//libStanServices.a' -L'/usr/local/lib/R/site-library/StanHeaders/lib/' -lStanHeaders -L'/usr/local/lib/R/site-library/RcppParallel/lib/' -ltbb  -L"/usr/local/lib/R/lib" -lR; \
fi 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant