Open XavierLaRochelle opened 2 weeks ago
Do you have the rstan
package installed? RStudio requires this package to be installed in order to provide code completions in Stan files.
Yes I have it installed. It's the latest version.
And still no completion :
Do you also see this in the latest RStudio release (2024.04.2)? I think you may be bumping into an issue that was fixed in the most recent patch release.
I re-installed RStudio and I am now on version 2024.4.2.764. Autocompletion is not working still.
Strange; it seems to be working on my side (tested with both the CRAN release 2.32.6 and dev version 2.35.0.9000).
What does executing this give you?
str(.rs.stan.rosetta())
For example, I see:
> str(.rs.stan.rosetta())
'data.frame': 627 obs. of 4 variables:
$ StanFunction: chr "abs" "acos" "acosh" "add" ...
$ RFunction : chr "abs" "acos" "acosh" "+" ...
$ Arguments : chr "(T);(complex)" "(T);(int)" "(T);(int)" "(int, T)" ...
$ ReturnType : chr "T;real" "T;real" "T;real" "T" ...
Similarly, what do you see for:
str(.rs.rpc.stan_get_completions("normal"))
I see:
> str(.rs.rpc.stan_get_completions("normal"))
List of 14
$ token : chr "normal"
$ results : chr [1:9] "normal_ccdf_log" "normal_cdf" "normal_cdf_log" "normal_id_glm_lpdf" ...
$ packages : chr [1:9] "function" "function" "function" "function" ...
$ quote : logi [1:9] FALSE FALSE FALSE FALSE FALSE FALSE ...
$ type : num [1:9] 6 6 6 6 6 6 6 6 6
$ meta : chr [1:9] "(real, real, T);(vector, vector, vector)" "(real, real, T);(vector, vector, vector)" "(real, real, T);(vector, vector, vector)" "(real, matrix, real, vector, T);(vector, row_vector, vector, vector, vector)" ...
$ fguess : chr ""
$ excludeOtherCompletions : 'rs.scalar' logi FALSE
$ excludeOtherArgumentCompletions: 'rs.scalar' logi FALSE
$ overrideInsertParens : 'rs.scalar' logi FALSE
$ cacheable : 'rs.scalar' logi TRUE
$ helpHandler : NULL
$ language : 'rs.scalar' chr "R"
$ context : num [1:9] 0 0 0 0 0 0 0 0 0
(these are both functions used behind the scenes by RStudio when retrieving completions for Stan files.)
I get the same thing as you for both functions :
My "about Rstudio" window looks weird however :
I don't know if that's a clue. I have no idea when this started but I recall it wasn't like that before.
Thanks! I'm surprised that it's still not working on your side.
Last thing... can you confirm that the Stan file you have open has the filetype Stan at the bottom right? Also, does it make a difference if you've already saved the file, versus working in an unsaved file?
Yes it's a Stan file :
I've tried saving and it doesn't change anything as far as I can tell. It's really weird behavior indeed.
@XavierLaRochelle Does rstan
load properly? I needed to first install matrixStats
which was missing.
> library(rstan)
Loading required package: StanHeaders
Error: package or namespace load failed for ‘rstan’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘matrixStats’
Once I installed it, everything worked properly.
Regarding earlier comment about:
"My "about Rstudio" window looks weird however :
That's a known issue. On macOS the RStudio/About RStudio
menu shows that smaller About dialog; use Help/About RStudio
to see the full dialog. See also: https://github.com/rstudio/rstudio/issues/10571
@ronblum I don't have this problem. Rstan's loading messages looks normal to me :
> library(rstan)
Loading required package: StanHeaders
rstan version 2.32.6 (Stan version 2.32.2)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
change `threads_per_chain` option:
rstan_options(threads_per_chain = 1)
Plus, I have the matrixStats package downloaded :
@gtritchie Thanks for the info!
System details
Steps to reproduce the problem
1 - Open a new .stan file. 2 - Write the beginning of a stan function like "norm" for "normal_lpdf()"
The autocompletion doesn't show up.
Describe the problem in detail
Back in 2018, it was announced in this blog post from the posit team that new stan related features would be implemented in Rstudio v1.2. I recently updated my Rstudio and I should be up to date on the latest features but things like stan autocompletion and document outline still does not work. I can't find any info online as to why it wouldn't have been implemented by now so I'm wondering if it's a problem on my end.
Describe the behavior you expected
For the example described above, an autocompletion dropdown menu should show up like it does for base R but it does not.