Skip to content

scan_deps() seems to fail when the input path is a file (not folder) #460

Description

@TimTaylor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions