Skip to content

Commit 681262c

Browse files
committed
Add fallback package name in case the DESCRIPTION file cannot be read.
When the DESCRIPTION file is not present, the package name is inferred to be the basename of pkgdir, which is what it used to be before #130.
1 parent e5506cb commit 681262c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Items for next release go here
44

5-
Extended `loo_pit()` for discrete data.
5+
* Extended `loo_pit()` for discrete data.
6+
* Fix regression (introduced in 2.4.0) in the compilation of packages with
7+
custom Stan functions by @mcol in #137
68

79
# rstantools 2.4.0
810

R/rstan_config.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,10 @@ rstan_config <- function(pkgdir = ".") {
214214
eigen_incl <- ifelse(utils::packageVersion('StanHeaders') >= "2.31",
215215
"#include <stan/math/prim/fun/Eigen.hpp>",
216216
"#include <stan/math/prim/mat/fun/Eigen.hpp>")
217-
pkgname <- unname(read.dcf("DESCRIPTION", "Package")[1, 1])
217+
pkgname <- tryCatch(unname(read.dcf("DESCRIPTION", "Package")[1, 1]),
218+
warning = function(w) {
219+
basename(pkgdir)
220+
})
218221
cat("#include <exporter.h>",
219222
eigen_incl,
220223
"#include <stan/math/prim/meta.hpp>",

0 commit comments

Comments
 (0)