RStudio "Cannot connect to R" - tried several versions

I'm not an R expert by any means, but I am required to support our end users and we're seeing an intermittent issue:

Cannot Connect to R
RStudio can't establish a connection to R.

I've installed R (4.3.2 (64-bit), but also happens with R 4.3.1) and then R Studio Desktop 2023.12.1+402 (and 2023.06.2+561), in that order.

I've blown away the RStudio directories from both appdata\local and appdata\Roaming and the issue persists. Usually a restart of the machine will fix it.

rdesktop.log:

2024-02-09T06:18:44.042Z ERROR Failed to load http://127.0.0.1:22597: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:22597/'
2024-02-09T06:18:54.540Z ERROR Exceeded timeout
2024-02-09T06:19:18.751Z ERROR Failed to load http://127.0.0.1:22597: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:22597/'
2024-02-09T06:19:32.097Z ERROR Main window closed unexpectedly

rsession-USERID.log:

2024-02-09T06:18:21.372143Z [rsession-USERID] ERROR Unable to retrieve user home path. HRESULT: 0x80070003; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::core::system::userSettingsPath(const class rstudio::core::FilePath &,const class std::basic_string<char,struct std::char_traits,class std::allocator > &,bool) src/cpp/core/system/Win32System.cpp:341

The user's home drive does exist. There are no denies in the Firewall.

I ran a RStudio Diagnostics Report. Results below:

RStudio Diagnostics Report

WARNING: This report may contain sensitive security information and / or
personally identifiable information. Please audit the below and redact any
sensitive information before submitting your diagnostics report.

Generated: Fri Feb 9 17:44:18 2024

RStudio Version

2023.12.1+402

Session Information

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8
[3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] testthat_3.1.5 devtools_2.4.5 usethis_2.1.6

loaded via a namespace (and not attached):
[1] miniUI_0.1.1.1 compiler_4.3.2 crayon_1.5.2 brio_1.1.3
[5] promises_1.2.0.1 Rcpp_1.0.9 stringr_1.4.1 callr_3.7.2
[9] later_1.3.0 fastmap_1.1.0 mime_0.12 R6_2.5.1
[13] htmlwidgets_1.6.2 profvis_0.3.7 shiny_1.7.4 rlang_1.1.1
[17] cachem_1.0.6 stringi_1.7.8 httpuv_1.6.6 fs_1.5.2
[21] pkgload_1.3.0 memoise_2.0.1 cli_3.4.1 magrittr_2.0.3
[25] ps_1.7.1 digest_0.6.29 processx_3.7.0 rstudioapi_0.14
[29] xtable_1.8-4 remotes_2.4.2 lifecycle_1.0.3 prettyunits_1.1.1
[33] vctrs_0.6.3 glue_1.6.2 urlchecker_1.0.1 sessioninfo_1.2.2
[37] pkgbuild_1.3.1 purrr_1.0.0 tools_4.3.2 ellipsis_0.3.2
[41] htmltools_0.5.4

System Information

sysname : Windows
release : 10 x64
version : build 19044
nodename : COMPUTERNAME
machine : x86-64
login : USERID
user : USERID
effective_user : USERID

Platform Information

OS.type : windows
file.sep : /
dynlib.ext : .dll
GUI : Rgui
endian : little
pkgType : win.binary
path.sep : ;
r_arch : x64

Environment Variables

ALLUSERSPROFILE : C:\ProgramData
APPDATA : C:\Users\USERID\AppData\Roaming
CLICOLOR_FORCE : 1
CommonProgramFiles : C:\Program Files\Common Files
CommonProgramFiles(x86) : C:\Program Files (x86)\Common Files
CommonProgramW6432 : C:\Program Files\Common Files
COMPUTERNAME : COMPUTERNAME
ComSpec : C:\Windows\system32\cmd.exe
CUDA_PATH : C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
CUDA_PATH_V10_1 : C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
CURL_CA_BUNDLE : C:/PROGRA~1/R/etc/curl-ca-bundle.crt
DEVOPS_TOKEN : *** redacted ***
DriverData : C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING : Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING : Default
GFORTRAN_STDERR_UNIT : -1
GFORTRAN_STDOUT_UNIT : -1
GIT_ASKPASS : rpostback-askpass
HOME : \PATHTHATDOESEXIST\USERID
HOMEDRIVE : H:
HOMEPATH :
HOMESHARE : \PATHTHATDOESEXIST\USERID
LOCALAPPDATA : C:\Users\USERID\AppData\Local
LOGONSERVER : \SERVERNAME
MSYS2_ENV_CONV_EXCL : R_ARCH
NUMBER_OF_PROCESSORS : 8
OneDrive : C:\Users\USERID\OneDrive - ORGANIZATION
OneDriveCommercial : C:\Users\USERID\OneDrive - ORGANIZATION
ORIGINAL_XDG_CURRENT_DESKTOP : undefined
OS : Windows_NT
PATH : c:\rtools43\x86_64-w64-mingw32.static.posix\bin;c:\rtools43\usr\bin;C:\Program Files\R\bin\x64;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\SASHome\x86\Secure\ccme4;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files\MiKTeX\miktex\bin\x64;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Users\USERID\AppData\Local\Microsoft\WindowsApps;C:\ProgramData\Anaconda3;C:\Program Files\RStudio\resources\app\bin\quarto\bin;C:\Program Files\RStudio\resources\app\bin\postback
PATHEXT : .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE : AMD64
PROCESSOR_IDENTIFIER : Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
PROCESSOR_LEVEL : 6
PROCESSOR_REVISION : 8c01
ProgramData : C:\ProgramData
ProgramFiles : C:\Program Files
ProgramFiles(x86) : C:\Program Files (x86)
ProgramW6432 : C:\Program Files
PROMPT : $P$G
PSModulePath : C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC : C:\Users\Public
PYTHONIOENCODING : utf-8
R_ARCH : /x64
R_CLI_HAS_HYPERLINK_IDE_HELP : true
R_CLI_HAS_HYPERLINK_IDE_RUN : true
R_CLI_HAS_HYPERLINK_IDE_VIGNETTE : true
R_COMPILED_BY : gcc 12.3.0
R_DOC_DIR : C:/PROGRA~1/R/doc
R_HOME : C:/PROGRA~1/R
R_INCLUDE_DIR : C:/PROGRA~1/R/include
R_LIBS_SITE : C:/PROGRA~1/R/site-library
R_LIBS_USER : C:\Users\USERID\AppData\Local/R/win-library/4.3
R_RTOOLS43_PATH : c:/rtools43/x86_64-w64-mingw32.static.posix/bin;c:/rtools43/usr/bin
R_RUNTIME : ucrt
R_SHARE_DIR : C:/PROGRA~1/R/share
R_USER : //\PATHTHATDOESEXIST/USERID
RMARKDOWN_MATHJAX_PATH : C:/Program Files/RStudio/resources/app/resources/mathjax-27
RS_LOCAL_PEER : \.\pipe\35727-rsession
RS_LOG_LEVEL : WARN
RS_RPOSTBACK_PATH : C:/Program Files/RStudio/resources/app/bin/rpostback.exe
RS_SHARED_SECRET : *** redacted ***
RSTUDIO : 1
RSTUDIO_CLI_HYPERLINKS : true
RSTUDIO_CONSOLE_COLOR : 256
RSTUDIO_CONSOLE_WIDTH : 80
RSTUDIO_DESKTOP_EXE : C:\Program Files\RStudio\rstudio.exe
RSTUDIO_MSYS_SSH : C:/Program Files/RStudio/resources/app/bin/msys-ssh-1000-18
RSTUDIO_PANDOC : C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools
RSTUDIO_PROGRAM_MODE : desktop
RSTUDIO_SESSION_PID : 18768
RSTUDIO_SESSION_PORT : 35727
RSTUDIO_USER_IDENTITY : USERID
RSTUDIO_WINUTILS : C:/Program Files/RStudio/resources/app/bin/winutils
SESSIONNAME : Console
SSH_ASKPASS : rpostback-askpass
SystemDrive : C:
SystemRoot : C:\Windows
TEMP : C:\Temp
TERM : xterm-256color
TMP : C:\Temp
TMPDIR : C:\ProgramData\Anaconda3\TEMP
UATDATA : C:\Windows\CCM\UATData{GUID}
USERDNSDOMAIN : *** redacted ***
USERDOMAIN : company
USERDOMAIN_ROAMINGPROFILE : company
USERNAME : *** redacted ***
USERPROFILE : C:\Users\USERID
windir : C:\Windows

R Version

platform : x86_64-w64-mingw32
arch : x86_64
os : mingw32
crt : ucrt
system : x86_64, mingw32
status :
major : 4
minor : 3.2
year : 2023
month : 10
day : 31
svn rev : 85441
language : R
version.string : R version 4.3.2 (2023-10-31 ucrt)
nickname : Eye Holes

R Home

C:/PROGRA~1/R

R Search Path

.GlobalEnv
tools:rstudio
package:stats
package:graphics
package:grDevices
package:utils
package:datasets
package:testthat
package:devtools
package:usethis
package:methods
Autoloads
package:base

R Library Paths

C:/Program Files/R/library

Loaded Packages

base : C:/PROGRA~1/R/library/base
brio : C:/Program Files/R/library/brio
cachem : C:/Program Files/R/library/cachem
callr : C:/Program Files/R/library/callr
cli : C:/Program Files/R/library/cli
compiler : C:/Program Files/R/library/compiler
crayon : C:/Program Files/R/library/crayon
datasets : C:/Program Files/R/library/datasets
devtools : C:/Program Files/R/library/devtools
digest : C:/Program Files/R/library/digest
ellipsis : C:/Program Files/R/library/ellipsis
fastmap : C:/Program Files/R/library/fastmap
fs : C:/Program Files/R/library/fs
glue : C:/Program Files/R/library/glue
graphics : C:/Program Files/R/library/graphics
grDevices : C:/Program Files/R/library/grDevices
htmltools : C:/Program Files/R/library/htmltools
htmlwidgets : C:/Program Files/R/library/htmlwidgets
httpuv : C:/Program Files/R/library/httpuv
later : C:/Program Files/R/library/later
lifecycle : C:/Program Files/R/library/lifecycle
magrittr : C:/Program Files/R/library/magrittr
memoise : C:/Program Files/R/library/memoise
methods : C:/Program Files/R/library/methods
mime : C:/Program Files/R/library/mime
miniUI : C:/Program Files/R/library/miniUI
pkgbuild : C:/Program Files/R/library/pkgbuild
pkgload : C:/Program Files/R/library/pkgload
prettyunits : C:/Program Files/R/library/prettyunits
processx : C:/Program Files/R/library/processx
profvis : C:/Program Files/R/library/profvis
promises : C:/Program Files/R/library/promises
ps : C:/Program Files/R/library/ps
purrr : C:/Program Files/R/library/purrr
R6 : C:/Program Files/R/library/R6
Rcpp : C:/Program Files/R/library/Rcpp
remotes : C:/Program Files/R/library/remotes
rlang : C:/Program Files/R/library/rlang
rstudioapi : C:/Program Files/R/library/rstudioapi
sessioninfo : C:/Program Files/R/library/sessioninfo
shiny : C:/Program Files/R/library/shiny
stats : C:/Program Files/R/library/stats
stringi : C:/Program Files/R/library/stringi
stringr : C:/Program Files/R/library/stringr
testthat : C:/Program Files/R/library/testthat
tools : C:/Program Files/R/library/tools
urlchecker : C:/Program Files/R/library/urlchecker
usethis : C:/Program Files/R/library/usethis
utils : C:/Program Files/R/library/utils
vctrs : C:/Program Files/R/library/vctrs
xtable : C:/Program Files/R/library/xtable

Installed Packages

          Package                    LibPath    Version

1 abind C:/Program Files/R/library 1.4-5
2 absmapsdata C:/Program Files/R/library 1.3.3
3 alfred C:/Program Files/R/library 0.2.0
4 antiword C:/Program Files/R/library 1.3.1
5 anytime C:/Program Files/R/library 0.3.9
6 companybrand C:/Program Files/R/library 0.3.1
7 arrow C:/Program Files/R/library 12.0.1
8 arsenal C:/Program Files/R/library 3.6.3
9 askgpt C:/Program Files/R/library 0.0.2
10 askpass C:/Program Files/R/library 1.1
11 assertthat C:/Program Files/R/library 0.2.1
12 AzureAuth C:/Program Files/R/library 1.3.3
13 AzureGraph C:/Program Files/R/library 1.3.2
14 backports C:/Program Files/R/library 1.4.1
15 base C:/Program Files/R/library 4.3.2
16 base64enc C:/Program Files/R/library 0.1-3
17 basictabler C:/Program Files/R/library 1.0.2
18 bbmle C:/Program Files/R/library 1.0.25
19 bdsmatrix C:/Program Files/R/library 1.3-6
20 beeswarm C:/Program Files/R/library 0.4.0
21 bench C:/Program Files/R/library 1.1.2
22 BH C:/Program Files/R/library 1.78.0-0
23 bigD C:/Program Files/R/library 0.2.0
24 BiocManager C:/Program Files/R/library 1.30.22
25 bit C:/Program Files/R/library 4.0.4
26 bit64 C:/Program Files/R/library 4.0.5
27 bitops C:/Program Files/R/library 1.0-7
28 blob C:/Program Files/R/library 1.2.3
29 bookdown C:/Program Files/R/library 0.34
30 boot C:/Program Files/R/library 1.3-28.1
31 brew C:/Program Files/R/library 1.0-8
32 brio C:/Program Files/R/library 1.1.3
33 broom C:/Program Files/R/library 1.0.1
34 BSDA C:/Program Files/R/library 1.2.1
35 bslib C:/Program Files/R/library 0.4.0
36 butcher C:/Program Files/R/library 0.3.0
37 cachem C:/Program Files/R/library 1.0.6
38 Cairo C:/Program Files/R/library 1.6-0
39 callr C:/Program Files/R/library 3.7.2
40 caret C:/Program Files/R/library 6.0-93
41 caTools C:/Program Files/R/library 1.18.2
42 cellranger C:/Program Files/R/library 1.1.0
43 checkmate C:/Program Files/R/library 2.1.0
44 chron C:/Program Files/R/library 2.3-58
[snip]

Rest of diagnostics:

586           zeallot C:/Program Files/R/library      0.1.0
587               zip C:/Program Files/R/library      2.2.1
588               zoo C:/Program Files/R/library     1.8-11


R System Profile: C:/PROGRA~1/R/library/base/R/Rprofile
--------------------------------------------------
### This is the system Rprofile file. It is always run on startup.
### Additional commands can be placed in site or user Rprofile files
### (see ?Rprofile).

### Copyright (C) 1995-2022 The R Core Team

### Notice that it is a bad idea to use this file as a template for
### personal startup files, since things will be executed twice and in
### the wrong environment (user profiles are run in .GlobalEnv).

.GlobalEnv <- globalenv()
attach(NULL, name = "Autoloads")
.AutoloadEnv <- as.environment(2)
assign(".Autoloaded", NULL, envir = .AutoloadEnv)
T <- TRUE
F <- FALSE
R.version <- structure(R.Version(), class = "simple.list")
version <- R.version            # for S compatibility

## for backwards compatibility only
R.version.string <- R.version$version.string

## NOTA BENE: options() for non-base package functionality are in places like
##            --------- ../utils/R/zzz.R

options(keep.source = interactive())
options(warn = 0)
# options(repos = c(CRAN="@CRAN@"))
# options(BIOC = "http://www.bioconductor.org")

## setting from an env variable added in 4.0.2
local({to <- as.integer(Sys.getenv("R_DEFAULT_INTERNET_TIMEOUT", 60))
    if (is.na(to) || to <= 0) to <- 60L
    options(timeout = to)
})
options(encoding = "native.enc")
options(show.error.messages = TRUE)
## keep in sync with PrintDefaults() in  ../../main/print.c :
options(scipen = 0)
options(max.print = 99999)# max. #{entries} in internal printMatrix()
options(add.smooth = TRUE)# currently only used in 'plot.lm'

if(!interactive())
    options(showErrorCalls = TRUE)

local({dp <- Sys.getenv("R_DEFAULT_PACKAGES")
       if(identical(dp, "")) ## it fact methods is done first
           dp <- c("datasets", "utils", "grDevices", "graphics",
                   "stats", "methods")
       else if(identical(dp, "NULL")) dp <- character(0)
       else dp <- strsplit(dp, ",")[[1]]
       dp <- sub("[[:blank:]]*([[:alnum:]]+)", "\\1", dp) # strip whitespace
       options(defaultPackages = dp)
    })

## Expand R_LIBS_* environment variables.
Sys.setenv(R_LIBS_SITE =
           .expand_R_libs_env_var(Sys.getenv("R_LIBS_SITE")))
Sys.setenv(R_LIBS_USER =
           .expand_R_libs_env_var(Sys.getenv("R_LIBS_USER")))

local({
    if(nzchar(tl <- Sys.getenv("R_SESSION_TIME_LIMIT_CPU")))
        setSessionTimeLimit(cpu = tl)
    if(nzchar(tl <- Sys.getenv("R_SESSION_TIME_LIMIT_ELAPSED")))
        setSessionTimeLimit(elapsed = tl)
})

.First.sys <- function()
{
    for(pkg in getOption("defaultPackages")) {
        res <- require(pkg, quietly = TRUE, warn.conflicts = FALSE,
                       character.only = TRUE)
        if(!res)
            warning(gettextf('package %s in options("defaultPackages") was not found', sQuote(pkg)),
                    call. = FALSE, domain = NA)
    }
}

## called at C level in the startup process prior to .First.sys
.OptRequireMethods <- function()
{
    pkg <- "methods" # done this way to avoid R CMD check warning
    if(pkg %in% getOption("defaultPackages"))
        if(!require(pkg, quietly = TRUE, warn.conflicts = FALSE,
                    character.only = TRUE))
            warning('package "methods" in options("defaultPackages") was not found',
                    call. = FALSE)
}

if(nzchar(Sys.getenv("R_BATCH"))) {
    .Last.sys <- function()
    {
        cat("> proc.time()\n")
        print(proc.time())
    }
    ## avoid passing on to spawned R processes
    ## A system has been reported without Sys.unsetenv, so try this
    try(Sys.setenv(R_BATCH=""))
}

local({
    if(nzchar(rv <- Sys.getenv("_R_RNG_VERSION_")))
        suppressWarnings(RNGversion(rv))
})

.sys.timezone <- NA_character_

local({
    ## create an active binding for .Library.site, so that it can be
    ## modified after the base environment is locked

    ## remove the binding in the lazyload data base 
    .Internal(mkUnbound(as.name(".Library.site")))
    siteLibrary <- character()
    slfun <- function(v) {
        if (!missing(v))
            siteLibrary <<- v
        siteLibrary
    }

    makeActiveBinding(".Library.site", slfun, baseenv())

    ## make .Library.site accessible also from global environment to
    ## preserve functionality of site profiles assigning to it directly
    ## (originally, site profiles were run in base environment)

    makeActiveBinding(".Library.site", slfun, globalenv())
})
###-*- R -*-

## this will break if R is on a network share
.Library <- file.path(chartr("\\", "/", R.home()), "library")

.Library.site <- Sys.getenv("R_LIBS_SITE")
if (!nzchar(.Library.site)) {
    .Library.site <- .expand_R_libs_env_var('%S')
    Sys.setenv(R_LIBS_SITE = .Library.site)
}
.Library.site <-
    if(.Library.site == "NULL") character() else unlist(strsplit(.Library.site, ";"))
.Library.site <- .Library.site[file.exists(.Library.site)]    
    
local({
    libs <- Sys.getenv("R_LIBS_USER")
    if (!nzchar(libs)) {
        libs <- .expand_R_libs_env_var('%U')
        Sys.setenv(R_LIBS_USER = libs)
    }
    libs <- if(libs == "NULL") character() else unlist(strsplit(libs, ";"))
    invisible(.libPaths(c(unlist(strsplit(Sys.getenv("R_LIBS"), ";")),
                          libs)))
})

local({
    popath <- Sys.getenv("R_TRANSLATIONS", "")
    if(!nzchar(popath)) {
        paths <- file.path(.libPaths(), "translations", "DESCRIPTION")
        popath <- dirname(paths[file.exists(paths)][1])
    }
    bindtextdomain("R", popath)
    bindtextdomain("R-base", popath)
    bindtextdomain("RGui", popath)
    assign(".popath", popath, .BaseNamespaceEnv)
})

if(nzchar(Sys.getenv("R_PAPERSIZE"))) {
    options(papersize = Sys.getenv("R_PAPERSIZE"))
} else {
    if(grepl("(canada|united.states)", Sys.getlocale("LC_MONETARY"),
             ignore.case = TRUE)) options(papersize = "letter")
    else options(papersize = "a4")
}

options(pager = if(length(grep("--ess", commandArgs()))) "console" else "internal",
        useFancyQuotes = (.Platform$GUI == "Rgui"),
        pdfviewer = Sys.getenv("R_PDFVIEWER", file.path(R.home("bin"), "open.exe")))

if(.Platform$GUI == "Rgui")
    Sys.setenv(GFORTRAN_STDOUT_UNIT = "-1", GFORTRAN_STDERR_UNIT = "-1")

local({
    br <- Sys.getenv("R_BROWSER", NA_character_)
    if(!is.na(br)) options(browser = br)
    tests_startup <- Sys.getenv("R_TESTS")
    if(nzchar(tests_startup)) source(tests_startup)
    ca_cert <- Sys.getenv("CURL_CA_BUNDLE", NA_character_)
    if(is.na(ca_cert) &&
       file.exists(ca_path <- file.path(R.home("etc"), "curl-ca-bundle.crt")))
        Sys.setenv(CURL_CA_BUNDLE = ca_path)
})

local({
    setRtools43Path <- 0
     setRtools43Path <- 1

    if (setRtools43Path) {
        rthome <- Sys.getenv("RTOOLS43_HOME", "c:/rtools43")
        rtpath <- paste0(rthome, "/x86_64-w64-mingw32.static.posix/bin;",
                         rthome, "/usr/bin")
        path <- Sys.getenv("R_CUSTOM_TOOLS_PATH", rtpath)
        Sys.setenv(R_RTOOLS43_PATH = rtpath)
        Sys.setenv(PATH = paste0(path, ";", Sys.getenv("PATH")))
    }
})


R Site Profile: C:/PROGRA~1/R/etc/Rprofile.site
--------------------------------------------------
# Things you might want to change

# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")

# set the default help type
# options(help_type="text")
  options(help_type="html")

# set a site library
# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")

# set a CRAN mirror
# local({r <- getOption("repos")
#       r["CRAN"] <- "http://my.local.cran"
#       options(repos=r)})

# Give a fortune cookie, but only to interactive sessions
# (This would need the fortunes package to be installed.)
#  if (interactive()) 
#    fortunes::fortune()



R User Profile: //PATH-TO-DFRS/USERID/.Rprofile
--------------------------------------------------
if (interactive()) {
  suppressMessages(require(devtools))
  suppressMessages(require(usethis))
  suppressMessages(require(testthat))
}

options(
  warnPartialMatchArgs = F,
  warnPartialMatchDollar = TRUE,
  warnPartialMatchAttr = TRUE,
  "pillar.print_min" = 15
)


R Site Environ: C:/PROGRA~1/R/etc/Renviron.site
--------------------------------------------------
(File does not exist)


R User Environ: //PATH-TO-DFRS/USERID/.Renviron
--------------------------------------------------
(File exists but is empty)


R Temporary Directory
--------------------------------------------------
C:\ProgramData\Anaconda3\TEMP\RtmpshJyK4


Files in R Temporary Directory
--------------------------------------------------
rs-graphics-c8cefeb4-a32a-4b82-9e40-72f80722dd04


Log file: C:/Users/USERID/AppData/Local/RStudio/log/rdesktop.log
--------------------------------------------------

2024-02-09T06:18:44.042Z ERROR Failed to load http://127.0.0.1:22597: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:22597/'

2024-02-09T06:18:54.540Z ERROR Exceeded timeout

2024-02-09T06:19:18.751Z ERROR Failed to load http://127.0.0.1:22597: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:22597/'

2024-02-09T06:19:32.097Z ERROR Main window closed unexpectedly

2024-02-09T06:21:30.006Z ERROR Failed to load http://127.0.0.1:11999: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:11999/'

2024-02-09T06:21:40.595Z ERROR Exceeded timeout

2024-02-09T06:22:05.030Z ERROR Failed to load http://127.0.0.1:11999: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:11999/'

2024-02-09T06:22:12.626Z ERROR Main window closed unexpectedly



Log file: C:/Users/USERID/AppData/Local/RStudio/log/rsession-USERID.log
--------------------------------------------------

2024-02-09T06:18:21.372143Z [rsession-USERID] ERROR Unable to retrieve user home path. HRESULT:  0x80070003; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::core::system::userSettingsPath(const class rstudio::core::FilePath &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool) src/cpp/core/system/Win32System.cpp:341
2024-02-09T06:21:07.349423Z [rsession-USERID] ERROR Unable to retrieve user home path. HRESULT:  0x80070003; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::core::system::userSettingsPath(const class rstudio::core::FilePath &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool) src/cpp/core/system/Win32System.cpp:341
2024-02-09T06:44:10.512853Z [rsession-USERID] ERROR Unable to retrieve user home path. HRESULT:  0x80070003; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::core::system::userSettingsPath(const class rstudio::core::FilePath &,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,bool) src/cpp/core/system/Win32System.cpp:341


User prefs: C:/Users/USERID/AppData/Roaming/RStudio/rstudio-prefs.json
--------------------------------------------------

(Not Found)

System prefs: C:/ProgramData/RStudio/rstudio-prefs.json
--------------------------------------------------

(Not Found)

User state: C:/Users/USERID/AppData/Local/RStudio/rstudio-desktop.json
--------------------------------------------------

{
    "context_id": "4DB3AFA0",
    "error_handler_type": "traceback"
}

Any ideas? We also have VMware Horizon Client installed.

I do note that hosts has this:

127.0.0.1 view-localhost # view localhost server

I removed this from a machine, flushed DNS and retried, but it still fails.

Hi @glenn.turner thank you for providing the diagnostic report.

I can see this error towards the end of the report:

2024-02-09T06:18:21.372143Z [rsession-USERID] ERROR Unable to retrieve user home path. ...

Further up, I can see your Environment variables show:

HOME : \PATHTHATDOESEXIST\USERID
HOMEDRIVE : H:
HOMEPATH :
HOMESHARE : \PATHTHATDOESEXIST\USERID

I am presuming that those values are replacements you have entered, but the H: suggests drives that are not local. Do you get a better result by setting the HOME environment variable to a local drive (eg: C:/User/${USERNAME})?

Thanks for the reply @Lachlan_Simpson . They are not local because we need to back up user data (we don't use roaming user profiles). Without changing those, is there anything we can do in terms of R- or RStudio-specific variables, preferably with those also referencing a variable so we can do it at install time per-machine, for example:

R_USER = ${USERPROFILE}\RStudioData

Hi @glenn.turner are you able to temporarily change the values to local values to test if it works please? Even if it isn't the desired solution, it will help us by providing more diagnostic information. Thanks

Hi, @Lachlan_Simpson one of our most experienced R users has changed HOME to a local drive and it's still an issue. His machine is currently unable to launch R Studio and connect to R.

rdesktop.log shows:

2024-03-20T04:25:22.451Z ERROR Failed to load http://127.0.0.1:8111: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:8111/'
2024-03-20T04:25:33.006Z ERROR Exceeded timeout

Nothing new in rsession-userid.log**
2024-03-20T04:25:55.790Z ERROR Failed to load http://127.0.0.1:8111: Error: ERR_CONNECTION_TIMED_OUT (-118) loading 'http://127.0.0.1:8111/'

Asking the user to run "C:\Program Files\RStudio\rstudio.exe" --run-diagnostics from a CMD.

Looks like the doco here Running a Diagnostic Report – Posit Support is out of date, as the .lnk is not in the expected location.

Hi @glenn.turner,

Thank you for your patience while we looked into this further, and for the feedback about our documentation. I will ask the team to review it and correct as necessary.

First, I can confirm that you have helped us find a bug, but unfortunately it's solution will only improve the error messages we see, rather than solve the issue you are experiencing.

Specifically, the error message "Unable to retrieve user home path. HRESULT:..." was unfortunately incorrect / misleading. You can see that an improvement has been merged already: implement fallback when computing user session directory by kevinushey · Pull Request #14464 · rstudio/rstudio · GitHub

To address the issue you have - the fact that the issue is apparently intermittent, and you are using network shares, makes us thing that the issue is related to timeouts during R session initialization.

Unfortunately the best solution we have in the short term is that you set a local directory for the user's home, as we can't control the starting of R sessions.

The R documentation does have a comprehensive explanation of the HOME and working directories, and how to set environment variables: R for Windows FAQ

It may be that the solution is a wrapper script that sets a local directory initially, but then an .Rprofile or .Renviron file resets the HOME after the session has initialized?

Thank you. You're right - the issue is with timeouts. Interesting to know that it might be R-related and nothing to do with R Studio itself. I'll try to test R natively without RStudio the next time I get a timeout.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.