summaryrefslogtreecommitdiff
path: root/patches/rstudio-server-multi-version/0007-detectRLocationsUsingR-Restore-R_HOME-at-the-end.patch
blob: 96eb6aaf32f3aa322bc2a698e3496b571d5cde75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From 36ed7d1c0036d40798a3ab5045f365e8e33692f3 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Sun, 20 Dec 2020 14:49:51 +0100
Subject: [PATCH 7/7] detectRLocationsUsingR: Restore R_HOME at the end.

This is not needed when detectRLocationsUsingR is only called by the
server process; for the multi-version feature, however, the rsession
process is calling it, and its R_HOME may not be unset.
---
 src/cpp/core/r_util/REnvironmentPosix.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/cpp/core/r_util/REnvironmentPosix.cpp b/src/cpp/core/r_util/REnvironmentPosix.cpp
index 83b60d7a1b..a909631e25 100644
--- a/src/cpp/core/r_util/REnvironmentPosix.cpp
+++ b/src/cpp/core/r_util/REnvironmentPosix.cpp
@@ -489,6 +489,7 @@ bool detectRLocationsUsingR(const std::string& rScriptPath,
    // (the normal semantics of invoking the R script are that it overwrites
    // R_HOME and prints a warning -- this warning is co-mingled with the
    // output of R and messes up our parsing)
+   std::string oldRHome = core::system::getenv("R_HOME");
    core::system::setenv("R_HOME", "");
 
    // if no R path was specified for a module, the module binary path MUST be specified
@@ -598,6 +599,8 @@ bool detectRLocationsUsingR(const std::string& rScriptPath,
       return false;
    }
 
+   // restore R_HOME
+   core::system::setenv("R_HOME", oldRHome);
    return true;
 }
 #endif
-- 
2.31.1