Error: package ‘StanHeaders’ 2.18.1 was found, but > 2.18.1 is required by ‘rstan’

Error: package ‘StanHeaders’ 2.18.1 was found, but > 2.18.1 is required by ‘rstan’

我正在写 an R package that depends on Stan and Rstan. I run the installation on an Azure machine Standard_D64_v3 and install r-base and r-cran-stan with sudo apt-get and rstan and Rcpp with R's install.packages()(among others, see shell setup script and R setup script).

这个过程上个月运行良好。今天我能够安装包(如欢迎消息所示),然后出现不兼容版本的运行时错误。

...
* DONE (PosteriorBootstrap)
Reloading attached PosteriorBootstrap
Welcome to PosteriorBootstrap, a parallel approach for adaptive non-parametric learning
Error: package ‘StanHeaders’ 2.18.1 was found, but > 2.18.1 is required by ‘rstan’
In addition: Warning message:
version 2.18.1.10 of ‘StanHeaders’ masked by 2.18.1 in /usr/lib/R/site-library 
Execution halted

我的代码中没有任何地方 StanHeaders 所以我怀疑问题出在不同的包之间。我该如何解决版本问题?

正如@nicola 在评论中所写,解决方法是重新安装 StanHeaders

install.packages("StanHeaders")

以前的代码可能因为新版本的 R 而停止工作,但我无法确定原因。