How to Resolve RStudio Start Up Error [R Session Process Exited With Code 1] On MacOS M1

Alexander N.V. Neri
The Desktop Diary
Published in
4 min readMay 23, 2022

--

Any first time user of RStudio (like me!) will most likely have problems in encountering errors in installing tools and apps. R Studio is not going to be an exception, and more often than not some software will demand more attention than usual for it to work.

ANYWAY, upon installing RStudio I have encountered a rather peculiar error when I try to run it:

Specifically, RStudio session process exited with code 1.

How to go around this issue?

The TL;DR Solution:

As stated in this Github issue, run this command in your terminal on your mac:

sudo chown $USER ~/.local/share

Tada! It should work now.

Still here? Here’s a small story to tell…

The Story

I tried scouring the community forum on how to resolve this particular issue. As stated by one of my colleagues who has been using RStudio for some time, this issue is very peculiar as the M1 versions feel more stable and faster than the other ones, so he was entirely surprised about encountering this problem.

Checking the forum threads here, here, and here, it seems that it is apparent that there is an inherent problem in the default behavior of the application upon installation.

Some of the details of the current environment:

  • Installing R Studio right now (as of 23 May 2022) will involve installing R version R-4.2.0-arm64.pkg from CRAN. This is a major version above the minimum requirement of R 3.3.0+. There might be API differences but I think this should be apparent for the current running R Studio install.
  • There have been posts from March 2021 (in as far as I can see) about the issue on MacOS installs. This is in the middle of the 1.4 version (specifically, 1.4.1106.5), which doesn’t exactly tell us anything, as who knows what actually is happening under the hood. Or maybe at least we know that there is a number of people having issues and that no one knows what exactly is happening.
  • Logs are empty, which I find strange or maybe that this might have been an undocumented issue and, as stated previously, no one know why.

So looking and poking around some more in the internet, I chanced upon this issue #8729 on Github:

What the issue tells us

Looking through the issue, we see a similar symptom:

Error Starting R
The R session failed to start.

ERROR MESSAGE
[No error available]
PROCESS OUTPUT
The R session process exited with code 1.

ERRORS
[No errors emitted]
OUTPUT
[No output emitted]
RECENT LOG

Nothing new here.

(and the log is empty. i.e., absolutely nothing useful shows up)

Again, same experience.

However,

I opened Console, started a search for rstudio, then launched 1.4. I get this error message, with Process listed as rsession:

Okay this is something I didn’t do, and maybe something different will turn up?

ERROR system error 13 (Permission denied) [path: /Users/ka37/.local/share/rstudio, target-dir: ]; OCCURRED AT rstudio::core::Error rstudio::core::FilePath::createDirectory(const std::string &) const src/cpp/shared_core/FilePath.cpp:809; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:1961

Looks like we got something here!

The Root Cause?

According to the poster kcarnold, it seems that the directory ~/.local/share is owned by root. This makes the /share folder inaccessible to users other than root. R Studio needs access to this folder and will be unable to start if the folder is not accessible.

After executing the ls -ld ~/.local/share command:

$  ~ ls -ld ~/.local/share
drwxr-xr-x 3 root staff 128 May 2022 /Users/crosse/.local/share

It is indeed owned by root. So the command:

sudo chown $USER ~/.local/share

Will make the directory owned by your user:

$ ~ ls -ld ~/.local/share
drwxr-xr-x 4 crosse staff 128 May 2022 /Users/crosse/.local/share

After this, I tried running RStudio and now we are in business!

Huge thanks to kcarnold for figuring things out!

Apparently, this also solves a similar problem when R Studio’s configuration directory is inaccessible. Do the same command on the configuration folder to make it accessible to you.

Good luck out there!

Read this post and more on my Typeshare Social Blog

--

--

Senior technical writer at Backbase. Previously @ NetSuite, game design and story writing. Studying data science and machine learning. Opinions my own.