Skip to content

allow user, admin to configure default .Rproj.user path - #15140

Merged
kevinushey merged 3 commits into
mainfrom
feature/global-scratch-path-location
Sep 11, 2024
Merged

kevinushey merged 3 commits into
mainfrom
feature/global-scratch-path-location

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Addresses #15098.

Approach

This PR augments each project's .Rproj file with a new ProjectId entry. This entry is just a GUID, but it's used to map to an external .Rproj.user folder when the user or administrator has enabled this.

Users can set a default "project user data directory" within Global Options... -> General -> Advanced:

Screenshot 2024-09-10 at 4 06 32 PM

If this value is set, then the project's state is then written to a folder at the path:

<projectUserDataDir>/<projectId>

instead of just the project's .Rproj.user.

The project ID above is generated on demand as a GUID, and stored as part of the project's .Rproj file.

Automated Tests

Not included.

QA Notes

Using the new UI mentioned above, try setting this directory to some value, e.g. /tmp/rstudio-data. Try creating a new project. After doing so, look within this directory -- you should see files like (for example):

$ tree /tmp/rstudio-data/
/tmp/rstudio-data/
└── 06e384c5-7599-4618-9656-c9c150e7d83a
    ├── B9D11BAB
    │   ├── bibliography-index
    │   ├── ctx
    │   ├── pcs
    │   │   ├── files-pane.pper
    │   │   ├── source-pane.pper
    │   │   ├── windowlayoutstate.pper
    │   │   └── workbench-pane.pper
    │   ├── persistent-state
    │   ├── presentation
    │   ├── profiles-cache
    │   ├── sources
    │   │   └── session-64440e8d
    │   │       └── lock_file
    │   └── tutorial
    └── shared
        └── notebooks
            └── patch-chunk-names

Documentation

TODO: We'll probably want to add some detail in the RStudio user guide + admin guide

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

it = dcfFields.find("ProjectId");
if (it != dcfFields.end())
{
std::string projectId = it->second.empty() ? core::system::generateUuid(true) : it->second;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This empty check is just me being defensive; it might not be necessary?

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@kevinushey
kevinushey merged commit 3cc2ba0 into main Sep 11, 2024
@kevinushey
kevinushey deleted the feature/global-scratch-path-location branch September 11, 2024 16:18
@ronblum

ronblum commented Oct 7, 2024

Copy link
Copy Markdown
Contributor

QA note: Keep in mind the project-level setting.

dmurdoch added a commit to haozhu233/kableExtra that referenced this pull request Jan 5, 2025
r3xth0r added a commit to r3xth0r/bivariate-lsm that referenced this pull request Jan 16, 2025
@brry

brry commented Jan 18, 2025 •

Copy link
Copy Markdown

If you need R code to obtain the location, I found this works:

rs_prefs <- paste0(Sys.getenv("APPDATA"),"/RStudio/rstudio-prefs.json")                 # Windows
if(Sys.info()["sysname"]!="Windows") rs_prefs <- "~/.config/rstudio/rstudio-prefs.json" # Unix
rjson::fromJSON(file=rs_prefs)$project_user_data_directory

Am I missing something in rstudioapi? Feels like it should have a get_rstudio_settings function...

Edit: this is indeed available:

rstudioapi::readRStudioPreference("project_user_data_directory", NULL)

Note that it returns "" if the setting is available but not set before.

brry added a commit to openHPI/codeoceanR that referenced this pull request Jan 18, 2025
brry added a commit to brry/course that referenced this pull request Jan 18, 2025
johann-wagner added a commit to johann-wagner/johann-wagner.github.io that referenced this pull request Feb 25, 2025
ericrobskyhuntley added a commit to ographiesresearch/urbanplanr that referenced this pull request Mar 15, 2025
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.

4 participants