Mathemilda
Mathemilda

Reputation: 129

RStudio cannot reach .Rhistory on Ubuntu

I was working with markdown file on RStudio. I have Ubuntu 14.04 on my laptop. I produce html files using knitr. I decided to clean my enviroment and added rm and gc commands at the end. Now here is a message in my console window:

Error attempting to read history from ~/.Rhistory: permission denied (is the .Rhistory file owned by root?)

What it means? Is it bad for my code?

Upvotes: 2

Views: 1245

Answers (2)

Matija Han
Matija Han

Reputation: 482

You are right - the first time you ran it, you were in sudo mode, and the .Rhistory file was created with root as the owner. Running RStudio as root would remove the symptom, but is not ideal. To be able to run it as a regular user, simply change the owner of the .Rhistory file:

sudo chown -c <user_name> .Rhistory

Upvotes: 3

Mathemilda
Mathemilda

Reputation: 129

In the best traditions of stackoverflow I reply to my own question! The problem occurred because when I first started R, I did it as su:

sudo R

so I can load a lot of useful libraries in /usr/lib/R/site-library and not in my account. As result .Rhistory became su file. It is possible for RStudio to see it if it is started as

sudo rstudio 

and then all is fine.

Upvotes: 1

Related Questions