Mark Heckmann
Mark Heckmann

Reputation: 11431

How to clear searchable history database in RStudio

In addition to the .Rhistory file,

RStudio maintains a database of all commands which you have ever entered into the Console. You can browse and search this database using the History pane. (source)

This one appears to still be searchable even when .Rhistory has been deleted.

How can I empty it? Cleaning it up might be necessary after, for example, installing from a private repo using a password, when I know other users have access to the computer. For example, I was a bit anxious seeing this popping up, after entering pass into the search field... (ノ゚0゚)ノ~

enter image description here

Upvotes: 2

Views: 2662

Answers (2)

Mark Heckmann
Mark Heckmann

Reputation: 11431

Thanks to Phann's hint, I found:

Deleting history_database seems to do the job. An empty database file is automatically recreated when starting RStudio again (tested on MacOS and Linux). The folder where to find history_database depends on your os and is described for the more general case here.

MacOS and Linux

~/.rstudio-desktop

Windows Vista, 7 and 8

%localappdata%\RStudio-Desktop  # (i.e. Phann's path, I guess)

Windows XP

%USERPROFILE%\Local Settings\Application Data\RStudio-Desktop

Linux RStudio-Server

~/.rstudio

Upvotes: 2

Phann
Phann

Reputation: 1327

On my Win7 system, I found the file history_database within C:/Users/../AppData/Local/RStudio-Desktop. It has a unix-like time stamp per line followed by a command.

I would guess that if you empty this file, the history is cleared. But I haven't tried the solution yet, so better make a copy of the file to be on the save side.

The file should be in a similar folder in Win10.

Upvotes: 1

Related Questions