[BUG] document_and_reload() fails when R/app_config.R contains an empty argument
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
Research direction
Start in R/reload.R at check_name_consistency(), around the codetools::walkCode() loop near line 90, and read how setwd() is used before that. Reproduce with the short script in the issue, then skip missing arguments in the loop and add an on.exit(setwd(...), add = TRUE) after the directory change. Done means an R/app_config.R containing df[, 1] no longer errors and getwd() is back in the original directory.
Written by the indexing model from the issue text.
Description
Describe the bug
document_and_reload() fails as soon as R/app_config.R contains a call with an empty argument, e.g. df[, 1].
check_name_consistency() walks the code with for (e in as.list(expr)[-1L]) codetools::walkCode(e, w) (R/reload.R#L90). When an argument is empty, e is a missing argument and walkCode() errors.
Because check_name_consistency() uses setwd() without on.exit(), the working directory is also left inside the project after the error.
To Reproduce
library(golem)
p <- file.path(
tempdir(),
"cncapp"
)
create_golem(
p,
open = FALSE,
check_name = FALSE
)
write(
"first_col <- function(df) df[, 1]",
file.path(
p,
"R",
"app_config.R"
),
append = TRUE
)
setwd(tempdir())
res <- try(document_and_reload(golem_wd = p))
getwd() == p
Output:
Error in w$call(e, w) : argument "e" is missing, with no default
[1] TRUE
Expected behavior
Empty arguments are skipped, the package is documented and reloaded, and the working directory is restored.
Additional context
Suggested fix (same pattern as {codetools}' default walker):
for (e in as.list(expr)[-1L]) {
if (!missing(e)) {
codetools::walkCode(
e,
w
)
}
}
plus on.exit(setwd(old_dir), add = TRUE) right after the setwd() call.
session info
R 4.3.3, Ubuntu 24.04, {golem} master (9938a41, version 1.0.1).
Generated by Claude Code
- Dominant language
- R
- Stars
- 947
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ThinkR-open/golem
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ThinkR-open/golem#1265 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ThinkR-open/golem#1259 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ThinkR-open/golem#1258 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ThinkR-open/golem#1256 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ThinkR-open/golem#1255 · 4 comments ·
All issues in ThinkR-open/golem
Similar issues
-
data_bio2rarify - doc - dimensions wrongPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
leppott/BioMonTools#162 ·
-
publications
Difficulty 1/5 Under an hour Newbie friendliness 85/100
epiforecasts/epiforecasts.github.io#161 ·
Maintainers usually reply within 1 day
-
Label `{sas}` chunk source as `sas` instead of `txt`, so it gets syntax highlightingPossibly taken @michaelmayer2 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microbiome/OMA#1031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
furrer-lab/abn#291 · 2 comments ·