Skip to content

Conversation

kv9898
Copy link
Contributor

@kv9898 kv9898 commented Oct 13, 2025

This PR goes in tandem with posit-dev/positron#9936 to allow auto-saving the workspace to .RData when the R session is shut down. The reason we need this is that in Windows Ark is having problems with propagating arguments to the R binary: posit-dev/positron#9927.

@DavisVaughan DavisVaughan self-requested a review October 13, 2025 20:04
Copy link
Contributor

@lionel- lionel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked and indeed we don't need to set these in the Unix path because R detects --save/--no-save by itself in R_common_command_line():

https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/main/CommandLineArgs.c#L114-L119

The Unix version of setup_r() callsRf_initialize_R() (

Rf_initialize_R(args.len() as i32, args.as_mut_ptr() as *mut *mut c_char);
) which calls that R_common_command_line() function.

I think we should merge this independently of whether we merge the Positron-side PR because we don't handle these arguments well currently.

@lionel- lionel- self-requested a review October 14, 2025 09:13
Copy link
Contributor

@lionel- lionel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavisVaughan Another way to set these options would be to call cmdlineoptions() from https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/gnuwin32/system.c#L1098 (it calls the R_common_command_line() function discussed above).

This is what Rgui does (https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/gnuwin32/front-ends/rgui.c#L60), as well as RStudio: https://github.com/rstudio/rstudio/blob/1062bea412a4410c0761ba65ca7ba65f019ee9b8/src/cpp/r/session/REmbeddedWin32.cpp#L235-L242.

The RStudio call site also has a note regarding initialisation of translation domains. It seems like we should look into calling that routine to initialise CLI arguments and other stuff, what do you think? It does quite a lot, so maybe we could pair to carefully review it and discuss implications.

@kv9898
Copy link
Contributor Author

kv9898 commented Oct 14, 2025

@DavisVaughan Another way to set these options would be to call cmdlineoptions() from https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/gnuwin32/system.c#L1098 (it calls the R_common_command_line() function discussed above).

This is what Rgui does (https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/gnuwin32/front-ends/rgui.c#L60), as well as RStudio: https://github.com/rstudio/rstudio/blob/1062bea412a4410c0761ba65ca7ba65f019ee9b8/src/cpp/r/session/REmbeddedWin32.cpp#L235-L242.

The RStudio call site also has a note regarding initialisation of translation domains. It seems like we should look into calling that routine to initialise CLI arguments and other stuff, what do you think? It does quite a lot, so maybe we could pair to carefully review it and discuss implications.

As a side note, I initially tried passing the arguments to cmdlineoptions, but somehow it was ignored (I probably did it wrongly)? I tried passing all arguments as they were (didn't work), and got an error saying unrecognized argument --interactive, and then I tried excluding --interactive argument and replacing the ark first argument with R.exe and it seems the arguments were ignored again.

@kv9898
Copy link
Contributor Author

kv9898 commented Oct 15, 2025

@DavisVaughan Another way to set these options would be to call cmdlineoptions() from https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/gnuwin32/system.c#L1098 (it calls the R_common_command_line() function discussed above).

This is what Rgui does (https://github.com/r-devel/r-svn/blob/48256015cc3c3e7cc2235179adccc60a641f6603/src/gnuwin32/front-ends/rgui.c#L60), as well as RStudio: https://github.com/rstudio/rstudio/blob/1062bea412a4410c0761ba65ca7ba65f019ee9b8/src/cpp/r/session/REmbeddedWin32.cpp#L235-L242.

The RStudio call site also has a note regarding initialisation of translation domains. It seems like we should look into calling that routine to initialise CLI arguments and other stuff, what do you think? It does quite a lot, so maybe we could pair to carefully review it and discuss implications.

The RStudio code seems to set the options separate from cmdlinoptions, so more similar to my proposal in this PR?

@kv9898 kv9898 requested a review from lionel- October 16, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants