Error in file(con, "r") : invalid 'description' argument

I have installed rstan and stanHeaders using the following commands:

install.packages(“https://win-builder.r-project.org/gdaEAY9p8V7I/StanHeaders_2.21.0-6.zip”, repos = NULL, type = “win.binary”)

install.packages(“https://win-builder.r-project.org/8GI7TA5e2eyj/rstan_2.21.2.zip”, repos = NULL, type = “win.binary”)

packageVersion(“rstan”)
[1] ‘2.21.2’
packageVersion(“StanHeaders”)
[1] ‘2.21.0.6’

The problem is that whenever I compile ANY stan model, I get the following kind of error:

> height_model <- stan_model('../stan_programs/height_model.stan', verbose=TRUE)

TRANSLATING MODEL ‘height_model’ FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model ‘height_model’.
COMPILING THE C++ CODE FOR MODEL ‘height_model’ NOW.
*OS: x86_64, mingw32; rstan: 2.21.2; Rcpp: 1.0.5; inline: 0.3.15 *
Error in file(con, “r”) : invalid ‘description’ argument

1 Like

Welcome to the Stan forums and sorry you’re getting an error! I’m pretty useless when it comes to Windows issues unfortunately, but hopefully @bgoodri, @bbbales2, @andrjohns or one of my other Windows literate colleagues will have an idea how to fix this.

In the meantime, a few questions that may help them troubleshoot this:

  • Which version of R do you have? In particular, is it greater or less than 4.0?
  • Is there anything in the file at "~/.R/Makevars" or "~/.R/Makevars.win"? You can just by running from R file.edit("~/.R/Makevars") and file.edit("~/.R/Makevars.win"), which should open those files.

Hello, also new here. I also used the lines above to update as per

Also ran the lines to clear out makevars. Edit: I now understand that the lines are supposed to open the files for edits but don’t seem to do anything in rstudio. In r I get ‘cant open file’ or similar. Perhaps I’m missing some makevars or something? Excuse my ignorance it’s all magic to me.

And get the same errors when trying to compile models: “Error in file(con, “r”) : invalid ‘description’ argument”.

packageVersion(“StanHeaders”)
[1] ‘2.21.0.5’
packageVersion(“rstan”)
[1] ‘2.21.2’

version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.2
year 2020
month 06
day 22
svn rev 78730
language R
version.string R version 4.0.2 (2020-06-22)
nickname Taking Off Again

I had a lot of trouble getting rstan to work when I updated to R4 a week or so ago, (particularly getting rtools4 to work) but it was working on the same models until today. I must’ve inadvertently updated. Let me know if I can add any info to help!

Can you do

traceback()

after the error occurs?

@jonah Thanks for your reply. I’m using “R version 4.0.2 (2020-06-22)”.

The two Makevars files you mentioned are almost identical. I have copy-pasted contents of both files below. I hope it tells you something.

Makevars:

STANHEADERS_SRC = (shell "(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e “message()” -e “cat(system.file(‘include’, ‘src’, package = ‘StanHeaders’, mustWork = TRUE))” -e “message()” | grep “StanHeaders”)

PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error
PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()")
PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()")

CXX_STD = CXX14

Makevars.win

STANHEADERS_SRC = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "message()" -e "cat(system.file('include', 'src', package = 'StanHeaders', mustWork = TRUE))" -e "message()" | grep "StanHeaders")

PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DRCPP_PARALLEL_USE_TBB=1
PKG_CXXFLAGS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::CxxFlags()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::CxxFlags()")
PKG_LIBS = $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "RcppParallel::RcppParallelLibs()") $(shell "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "StanHeaders:::LdFlags()")

CXX_STD = CXX14

@bgoodri

Thanks for your reply. Here is the output of traceback()

traceback()
6: file(con, “r”)
5: readLines(file.path(makevar_files))
4: grep(“^CXX.*FLAGS”, readLines(file.path(makevar_files)), value = TRUE)
3: .remove_march_makevars()
2: cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap("“,
model_name, “");”, sep = “”), includes = inc, plugin = “rstan”,
save_dso = save_dso | auto_write, module_name = paste(“stan_fit4”,
model_cppname, “_mod”, sep = “”), verbose = verbose)
1: stan_model(”…/stan_programs/height_model.stan", verbose = TRUE)

That is what I thought. Thanks!

does this mean you figured out a solution to this recurring problem? :)

That particular problem has only occurred once so far, but it should now be fixed on

1 Like

@Chiraz_BenAbdelkader Can you try installing from these updated links

install.packages(
"https://artifacts.r-hub.io/StanHeaders_2.21.0-6.tar.gz-5af2069f840e9b971ee5b0e175da5ea6/StanHeaders_2.21.0-6.zip",
repos = NULL, type = "win.binary")
install.packages(
"https://artifacts.r-hub.io/rstan_2.21.2.tar.gz-3145e4a7fcd4016d378efd0e537d8b91/rstan_2.21.2.zip",
repos = NULL, type = "win.binary")

and let us know if you still get errors? Thanks!

Edit: these are the same links as the updated links in the post @bgoodri linked to. I hadn’t seen his response.

@jonah That worked beautifully, thank you so much!

1 Like

Also worked for me!

1 Like

@Chiraz_BenAbdelkader, @bhogan Great, glad it’s working for you both now!

1 Like