scan_deps() seems to fail if the path input is a file rather than a folder.
This fails:
dir.create(f <- tempfile())
od <- setwd(f)
tryCatch(
finally = {
setwd(od)
unlink(f, recursive = TRUE)
},
expr = {
cat("dplyr::filter(mtcars, cyl == 4)\n", file = "example.R")
pkgdepends::scan_deps("example.R", root = ".")
}
)
#> Error in `writeLines()`:
#> ! can only write character objects
This works:
dir.create(f <- tempfile())
od <- setwd(f)
tryCatch(
finally = {
setwd(od)
unlink(f, recursive = TRUE)
},
expr = {
dir.create("folder")
cat("dplyr::filter(mtcars, cyl == 4)\n", file = "folder/example.R")
pkgdepends::scan_deps("folder", root = ".")
}
)
#>
#> Dependencies:
#> + dplyr @ example.R
Created on 2026-04-08 with reprex v2.1.1
scan_deps()seems to fail if the path input is a file rather than a folder.This fails:
This works:
Created on 2026-04-08 with reprex v2.1.1