posit-dev / posit-dev/ark

Ark: Move away from R startup pass through of `--` towards explicit CLI arguments that we support

Open
#708 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
337
Forks
32
Avg merge
8d 17h
Merged PRs (30d)
11

Description

Right now, ark has an argument "pass through" method of -- that passes on any command line arguments to R

In Positron we set a few, like --interactive and --quiet and --no-restore-data, but the user has a chance to set some too:

Image

This is actually absolutely not working as intended right now. On Windows, we aren't even passing these arguments through to R's cmdlinearg utility
https://github.com/posit-dev/ark/blob/d6ab389bb828db56850948f10b27e3161285be47/crates/ark/src/sys/windows/interface.rs#L55-L56

But here's the thing, I don't think we should. In RStudio, there is no option to just pass whatever flags you want through to R. RStudio exposes a UI to set blessed options, and then it does whatever internal magic is needed to mimic things like --no-init-file (which would be to set pRP->LoadInitFile = loadInitFile ? TRUE : FALSE, not to pass --no-init-file through to R directly).

This is a good thing because it would put ark in control over the limited set of blessed options you can tweak while starting R. For example, we'd never want anyone to pass -e to run a single expression and then exit.

Here is the set of ark options

--connection_file
--startup-file
--session-mode
--no-capture-streams
--version
--log
--install
--help

I think we should also add this explicit set of R options instead of --

--r-quiet

# These default to TRUE like R, so the flag name is `no`
--r-no-init-file
--r-no-site-file
--r-no-environ

# I vote we default these to FALSE internally, unlike R,
# which means we also remove the `"no"` from their R option name
--r-save
--r-restore-data
--r-restore-history

# Advanced user customization, sometimes for workbench / security
--r-max-connections=N
--r-max-ppsize=N
--r-min-nsize=N
--r-min-vsize=N

# Special, but common
# We would already _default_ to no-save, no-restore, so this would practically
# add no-init-file, no-site-file, no-environ
--r-vanilla

That is the complete list of what I think we should add as explicit options out of this set from R's help page:

Options:
  -h, --help            Print short help message and exit
  --version             Print version info and exit
  --encoding=ENC        Specify encoding to be used for stdin
  --encoding ENC
  RHOME			Print path to R home directory and exit
  --save                Do save workspace at the end of the session
  --no-save             Don't save it
  --no-environ          Don't read the site and user environment files
  --no-site-file        Don't read the site-wide Rprofile
  --no-init-file        Don't read the user R profile
  --restore             Do restore previously saved objects at startup
  --no-restore-data     Don't restore previously saved objects
  --no-restore-history  Don't restore the R history file
  --no-restore          Don't restore anything
  --vanilla		Combine --no-save, --no-restore, --no-site-file,
			--no-init-file and --no-environ
  --no-readline         Don't use readline for command-line editing
  --max-connections=N   Set max number of connections to N
  --max-ppsize=N        Set max size of protect stack to N
  --min-nsize=N         Set min number of fixed size obj's ("cons cells") to N
  --min-vsize=N         Set vector heap minimum to N bytes; '4M' = 4 MegaB
  -q, --quiet           Don't print startup message
  --silent              Same as --quiet
  -s, --no-echo         Make R run as quietly as possible
  --interactive         Force an interactive session
  --verbose             Print more information about progress
  -d, --debugger=NAME   Run R through debugger NAME
  --debugger-args=ARGS  Pass ARGS as arguments to the debugger
  -g TYPE, --gui=TYPE	Use TYPE as GUI; possible values are 'X11' (default)
			and 'Tk'.
  --arch=NAME		Specify a sub-architecture
  --args                Skip the rest of the command line
  -f FILE, --file=FILE  Take input from 'FILE'
  -e EXPR               Execute 'EXPR' and exit

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with crates/ark/src/sys/windows/interface.rs around lines 55-56 and compare the existing -- pass-through behavior with the proposed explicit Ark and R options. Trace how command-line arguments reach R, then define completion as supporting the listed explicit options without accepting arbitrary pass-through flags, including the documented R startup settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.