Skip to content

cpp_source reports error with temp file path #194

Closed
@renkun-ken

Description

@renkun-ken

cpp11::cpp_source() by default uses a temp directory to store the source files to compile. When an error occurs, however, the errors are also reported with a temp path like the following:

> cpp11::cpp_source("indention.cpp")                                                                                                                                                   
/tmp/RtmptYYXie/file3b9a74895bd2a/src/indention.cpp:6:47: error:xwas not declared in this scope
    6 | SEXP detect_comments(SEXP content, SEXP row = x)
      |                                               ^
make: *** [/usr/lib/R/etc/Makeconf:177: /tmp/RtmptYYXie/file3b9a74895bd2a/src/indention.o] Error 1
make: *** Waiting for unfinished jobs....
Error: Compilation failed.
Backtrace:
1: stop("Compilation failed.", call. = FALSE)
2: cpp11::cpp_source("indention.cpp")

where these files are immediately removed. If a code editor (e.g. VS Code) supports detecting file links in the terminal output, user could not jump to the line and column from these paths as they don't exist anymore.

I guess it might make more sense to show the original file paths in the error output.

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