Configurable Working Directory for the R Process(es)
Is your feature request related to a problem? Please describe.
I recently found myself in a project which contained R code in a subfolder, where R was largely isolated to that folder. While you could make the case that this work should have been taken out of the project and given its own git repository, things just weren't that mature yet. Since it wasn't in the root folder, the R extension complained about missing languageserver.
For this usecase it would be great to be able to change the starting directory for the R process in this project to this subfolder. This is where I ues renv and have languageserver installed and all the other packages used by the R code.
Some issues touch upon this topic:
- Issue #1478: Several users have headaches over renv settings not being picked up
- Issue #1473: Executables and paths for R
- Issue #148 (from 2019): Very related issue
Describe the solution you'd like
Could we have a r.workingDirectory setting? And perhaps an interactive selector for this if there are several good candidates? So something like this in properties:
{
"r.workingDirectory": {
"type": "string",
"default": "",
"scope": "resource",
"description": "Working directory for R processes"
}
}
Describe alternatives you've considered
I'd have to restructure all R projects in a monolithic project to run of one and the same renv.lock file in the project directory. Sure you could fork out each of those into their own repos, but as alluded to before, it'd be nice if this wasn't the forced solution to this.
Additional context
I have started on this in a fork.
Isn't it when you open an R script from a folder, and create an R terminal upon that script, R will always start from that folder as the working directory?
Isn't it when you open an R script from a folder, and create an R terminal upon that script, R will always start from that folder as the working directory?
What you point out is just one out of several situation where this extension may start an R process:
My particular situation addresses the workspaces setting, I'd like my R processes in my project to start elsewhere, not always in the project root.
But I wouldn't mind having control of the other scenarios also. I'd like the languageserver to start where I have burried my renv settings also for example, thats where I have the languageserver package installed in the first place.
I would like to bump this. We currently have a few projects where the R project does not reside in the project root and it uses renv to manage its library. Being able to specify the working directory would be very useful.