-
Notifications
You must be signed in to change notification settings - Fork 27
Description
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.
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.