Skip to content

message() output during R startup appears red in Positron console #1101

@jennybc

Description

@jennybc

I noticed this while working on #1088 and playing around with message() in .Rprofile, both inside and outside of session init hooks.

message() calls from .Rprofile (and presumably the site file) render like an error, i.e. in red in the Positron console. The same message() call renders in the normal text color when executed interactively. All of those startup messages are emitted with message() too.

Image

My understanding of what's going on:

ark registers a globalCallingHandlers() message handler (.ps.errors.globalMessageHandler in errors.R) that intercepts message() conditions and redirects output to stdout via cat(). This makes "normal" message() output look "normal".

During startup, .Rprofile is sourced inside top_level_exec() (in startup.rs), which resets the R handler stack. The global calling handlers are not active in that context, so message() falls through to R's default behavior, which is to write to stderr. And Positron styles all stderr output with --vscode-positronConsole-errorForeground (red).

I don't know what the right thing to do about this is.

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