`message()` output during R startup appears red in Positron console
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 337
- Forks
- 32
- Avg merge
- 8d 17h
- Merged PRs (30d)
- 11
Description
I noticed this while working on https://github.com/posit-dev/ark/pull/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with .ps.errors.globalMessageHandler in crates/ark/src/modules/positron/errors.R and top_level_exec() in crates/ark/src/startup.rs, then trace how the handler stack changes while .Rprofile is sourced. Compare startup and interactive message() output in the Positron console; done means startup messages no longer appear as red errors while stderr behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r, rust
- Domain
- backend, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100