Skip to content

unlink(NULL) fails in R code run by Posit Assistant #19794

Description

@kevinushey

System details

RStudio Edition : Desktop
RStudio Version : development build of main (2958c9c803)
OS Version      : macOS (arm64)
R Version       : 4.6

Steps to reproduce the problem

Run this in the Console, which evaluates the expression with the same file-access checks that apply to R code run by Posit Assistant:

.rs.chat.withGuardrails(unlink(NULL))

Describe the problem in detail

The call fails:

Error in path.expand(paths) : invalid 'path' argument

The check added to unlink() passes its argument to Sys.glob(), which does not accept NULL.

This matters beyond a literal unlink(NULL): some packages make that call while cleaning up. rmarkdown::render(), for example, calls unlink() on its list of temporary files as it exits, and that list is NULL when rendering fails early. The cleanup then fails in turn, so Posit Assistant is shown invalid 'path' argument in place of the error that stopped the render.

Describe the behavior you expected

unlink(NULL) does nothing and returns 0, as it does when run outside Posit Assistant.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions