-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Recompiling stan code fails after changes have been made but then works after restarting R session #982
Comments
This was the result of a bug in stanc which was fixed here. I have backported the change (it's only one line) to 2.26 here: https://github.com/stan-dev/stanc3/tree/lexer-patch-v2.26.1 I can provide a built stancjs if it helps @hsbadr |
Awesome, thank you @WardBrian - this may be a silly question but do you know how I can install the version of stanc which has the fix? Typically I install stan through the R packages |
Reinstalling the packages seems to work. I will close this issue. |
I’m actually going to reopen this, because I don’t believe the issue has been resolved on the RStan end |
I have the same issue with the rstan & StanHeaders versions installed from https://mc-stan.org/r-packages/. The CRAN versions work fine. For me, if I compile the model with
|
@WardBrian Sorry! I should be able to look into this when I return to office early in March, Right now, it'd be helpful if we could test the remove.packages(c("rstan", "StanHeaders"))
remotes::install_git("https://github.com/stan-dev/rstan", subdir = "StanHeaders", ref = "experimental")
remotes::install_git("https://github.com/stan-dev/rstan", subdir = "rstan/rstan", ref = "experimental") v2.26 is a temporary release to address backward compatibility issues on CRAN. So, it has many patches that cause unexpected issues and may not be worth fixing for the transition. |
I can confirm that it errors under 2.26.4 but not the experimental branch, using the following code to test: bad_mod <- "parameters { real no_semicolon } model {}"
good_mod <- "parameters { real semicolon; } model {}"
rstan::stanc(model_code = bad_mod)
rstan::stanc(model_code = good_mod) Is it possible to backport the relevant changes/patches to 2.26? This error has come up a few times on the forum already, and will probably come up more once it's out on CRAN |
I would expect it to be resolved on experimental if it’s using a recent stancjs Yes, I backported it on this branch: I can provide a built stancjs from this branch no problem, let me know how would be best to get it to you |
The problem could in the unnecessary (Stan/Math) patches we made for CRAN (check @WardBrian If it's a |
remove.packages(c("rstan", "StanHeaders"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos"))) |
I can confirm that the error is resolved under the new packages thanks @WardBrian and @hsbadr! Closing this issue. |
Summary:
I have a small stan script that compiles and runs fine. I then make some small changes (e.g. adding some additional data parameters). I rerun
stan(...)
and get the following output:If I then, restart my R session and run
stan(...)
compilation happens without error and sampling runs fine.Reproducible Steps:
I have the following code in a .stan file:
I run this using (works fine):
I then change my .stan file to:
And try and rerun using (not restarting R):
Sometimes (though not all the time) this will produce an output like:
Though the exact details of
line 23, column 21 to column 22,
change every timestan
is run (without changing the code).If I restart my R session and run the following code it will compile without error:
Many thanks for your help :)
RStan Version:
StanHeaders_2.26.6
R Version:
Operating System:
The text was updated successfully, but these errors were encountered: