You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
the R session crashes at startup when R_HISTSIZE is 0 and fails to start when it is negative #19690
RStudio Edition : Desktop and Server
RStudio Version : main (2026.12 development)
OS Version : all (reproduced on macOS)
R Version : all
Steps to reproduce the problem
Put R_HISTSIZE=0 in ~/.Renviron (a way to keep R from saving command history), in a directory where a .Rhistory file exists.
Start RStudio.
Or: set R_HISTSIZE=-1 and start RStudio.
Describe the problem in detail
With R_HISTSIZE=0 and a .Rhistory to load, the R session crashes during startup (segmentation fault). The backtrace ends in ConsoleHistory::loadFromFile() -> readCollectionFromStream() -> circular_buffer::insert(): RStudio uses R_HISTSIZE as the capacity of the session's in-memory console history, and inserting the loaded lines into a zero-capacity buffer writes through an invalid slot.
With a negative R_HISTSIZE, the session fails to start with Unexpected exception: circular_buffer, because the negative capacity becomes a huge one.
Without a .Rhistory, R_HISTSIZE=0 starts, but the session keeps no command history: the History pane shows none of the session's commands, and the Console's command recall is empty after a browser reload.
R reads R_HISTSIZE differently. Per ?savehistory, it "controls the number of lines that are saved" to the history file (on quit, and by savehistory()), and "there is no limit on the number of lines of history retained during a session". R reads it at the time of saving, accepts 0 (save nothing), and ignores negative or invalid values with a warning, using its default of 512.
RStudio starts with any R_HISTSIZE. As in R, R_HISTSIZE limits how many commands are written to the history file, and doesn't limit the history kept during the session; 0 saves none, and negative or invalid values are ignored.
Activity
cap the session's history capacity at 100,000, and at least 1
test that savehistory() saves only the last R_HISTSIZE commands
don't cap the session's history capacity
keep the console history in a circular_buffer_space_optimized
limit only the saved history to R_HISTSIZE, as R does (#19691)