summaryrefslogtreecommitdiff
path: root/patches/rstudio-server-multi-version/0006-Look-at-.local-share-rstudio-r-versions-for-custom-R.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/rstudio-server-multi-version/0006-Look-at-.local-share-rstudio-r-versions-for-custom-R.patch')
-rw-r--r--patches/rstudio-server-multi-version/0006-Look-at-.local-share-rstudio-r-versions-for-custom-R.patch92
1 files changed, 92 insertions, 0 deletions
diff --git a/patches/rstudio-server-multi-version/0006-Look-at-.local-share-rstudio-r-versions-for-custom-R.patch b/patches/rstudio-server-multi-version/0006-Look-at-.local-share-rstudio-r-versions-for-custom-R.patch
new file mode 100644
index 0000000..48150c3
--- /dev/null
+++ b/patches/rstudio-server-multi-version/0006-Look-at-.local-share-rstudio-r-versions-for-custom-R.patch
@@ -0,0 +1,92 @@
1From e309b35a2f59a268442de8e1684ddd72fc9e5166 Mon Sep 17 00:00:00 2001
2From: Ricardo Wurmus <rekado@elephly.net>
3Date: Sun, 20 Dec 2020 00:25:42 +0100
4Subject: [PATCH 6/7] Look at ~/.local/share/rstudio/r-versions for custom R
5 versions.
6
7---
8 src/cpp/server_core/RVersionsScanner.cpp | 20 +++++++++++++++++++
9 .../include/server_core/RVersionsScanner.hpp | 1 +
10 src/cpp/session/SessionClientInit.cpp | 8 +++++++-
11 3 files changed, 28 insertions(+), 1 deletion(-)
12
13diff --git a/src/cpp/server_core/RVersionsScanner.cpp b/src/cpp/server_core/RVersionsScanner.cpp
14index af5974c24d..7504fbb1ff 100644
15--- a/src/cpp/server_core/RVersionsScanner.cpp
16+++ b/src/cpp/server_core/RVersionsScanner.cpp
17@@ -2,6 +2,7 @@
18 * RVersionsScanner.cpp
19 *
20 * Copyright (C) 2021 by RStudio, PBC
21+ * Copyright (C) 2020 Ricardo Wurmus
22 *
23 * Unless you have received this program directly from RStudio pursuant
24 * to the terms of a commercial license agreement with RStudio, then
25@@ -138,6 +139,11 @@ void RVersionsScanner::setFallbackVersion()
26 }
27
28 std::vector<r_util::RVersion> RVersionsScanner::getRVersions()
29+{
30+ return RVersionsScanner::getRVersions(FilePath(""));
31+}
32+
33+std::vector<r_util::RVersion> RVersionsScanner::getRVersions(FilePath userFile)
34 {
35 if (!cachedVersions_.empty())
36 return cachedVersions_;
37@@ -173,6 +179,20 @@ std::vector<r_util::RVersion> RVersionsScanner::getRVersions()
38 }
39 }
40
41+ if (!userFile.isEmpty() && (userFile.exists()))
42+ {
43+ std::string contents;
44+ Error error = core::readStringFromFile(userFile, &contents, string_utils::LineEndingPosix);
45+ if (!error)
46+ {
47+ parseRVersionsFile(userFile, contents, &rHomeDirs, &rEntries);
48+ }
49+ else
50+ {
51+ LOG_ERROR(error);
52+ }
53+ }
54+
55 // scan for available R versions
56 using namespace r_util;
57 std::vector<r_util::RVersion> versions = r_util::enumerateRVersions(
58diff --git a/src/cpp/server_core/include/server_core/RVersionsScanner.hpp b/src/cpp/server_core/include/server_core/RVersionsScanner.hpp
59index 840429edf5..3cf9b7d79e 100644
60--- a/src/cpp/server_core/include/server_core/RVersionsScanner.hpp
61+++ b/src/cpp/server_core/include/server_core/RVersionsScanner.hpp
62@@ -45,6 +45,7 @@ public:
63 // scans for r versions and returns any that were found
64 // subsequent calls return cached versions found in initial scan
65 std::vector<r_util::RVersion> getRVersions();
66+ std::vector<r_util::RVersion> getRVersions(core::FilePath userFile);
67
68 bool detectRVersion(const core::FilePath& rScriptPath,
69 core::r_util::RVersion* pVersion,
70diff --git a/src/cpp/session/SessionClientInit.cpp b/src/cpp/session/SessionClientInit.cpp
71index 52523fc896..34dad727c4 100644
72--- a/src/cpp/session/SessionClientInit.cpp
73+++ b/src/cpp/session/SessionClientInit.cpp
74@@ -511,8 +511,14 @@ void handleClientInit(const boost::function<void()>& initFunction,
75 sessionInfo["multi_session"] = options.multiSession();
76
77 // Read versions from /etc/rstudio/r-versions
78+ // ...and read from a user-controlled file
79+ FilePath userRDirsPath =
80+ options.userScratchPath().completePath("r-versions");
81+
82 json::Array availableRVersionsJson;
83- std::vector<r_util::RVersion> versions = RVersionsScanner().getRVersions();
84+ std::vector<r_util::RVersion> versions =
85+ RVersionsScanner().getRVersions(userRDirsPath);
86+
87 for (r_util::RVersion& rEntry : versions)
88 {
89 json::Object rVersionJson;
90--
912.31.1
92