Skip to content

R console doesn't recall erroneous code after pressing up arrow #16006

Closed

Description

@atakanekiz

System details

RStudio Edition :  Desktop
RStudio Version : 2024.12.1+563
OS Version      : x86_64-w64-mingw32/x64  Windows 11 x64 (build 26100)
R Version       : R version 4.4.3 (2025-02-28 ucrt)

Description of the problem and steps to reproduce it

R session doesn't seem to remember previously executed erroneous code

  1. Open up an .rmd file and starting working on the code in chunks
  2. When code execution fails with an error either in the console or in the chunks, up arrow doesn't recall this last code in the R console (history pane shows the erroneous code but R console doesn't recall)
  3. Problem doesn't occur when R executable is used (wrong code is recalled upon pressing up arrow)

Although I can't reproduce it easily, sometimes the same situation occurs when trying to recall successfully executed lines as well. In such cases clearing the console with Ctrl+L helped but not always. I know this is not much info but I will try to update the issue if I can get it to repeat.

Describe the behavior you expected

Regardless of whether a code successfully executes or not, up arrow should bring back the last code. This is helpful especially for correcting arguments in multi-line function calls

QA Notes

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

Activity

  1. added
    new
    on May 9, 2025
  2. ronblum commented on May 12, 2025

    @ronblum
    Contributor

    @atakanekiz Thank you for raising the issue! I can reproduce it in RStudio Desktop 2024.12.1 on Windows 11. We've marked it for review.

  3. added and removed
    new
    on May 12, 2025
  4. ronblum commented on May 12, 2025

    @ronblum
    Contributor

    Note: This is a regression, as it works correctly in version 2024.09.1+388.

  5. added theissue type on May 12, 2025
  6. atakanekiz commented on May 15, 2025

    @atakanekiz
    Author

    Hey there!

    With the latest version of RStudio (2025.05.0+496 "Mariposa Orchid" Release (f0b76cc, 2025-05-04)), the problem seems to be solved, thanks!

    In this version though, I am having a different type of a problem which was raised previously (#16000). Code chunk continues executing without stopping the flow. It would be a better behavior if the execution stops when encountered an error. I just wanted to drop this as a comment to possibly help narrow down the issue. Thanks for all you do!

    # forgot to load the package
    # library(dplyr)
    
    # Continues executing after error
    x<- left_join(x, y, by=c("x_var"="y_var"))
    
    >Error in left_join(meta, metab_patients, by = c(patient = "TCGA.Designation")) : 
    >  could not find function "left_join"
    >Error during wrapup: not that many frames on the stack
    >Error: no more error handlers available (recursive errors?); invoking 'abort' restart
    
    ...
    
  7. kevinushey commented on May 15, 2025

    @kevinushey
    Collaborator

    Thanks -- this is a known issue, and we're hoping to fix this in an upcoming patch release of RStudio. If you'd like to test, builds of the upcoming patch release are being published at https://dailies.rstudio.com/rstudio/mariposa-orchid/.

  8. added this to the Patch 2025.05.1 milestone on May 23, 2025
  9. ronblum commented on May 27, 2025

    @ronblum
    Contributor

    This is still failing (surprise, because I thought that I saw it work earlier).

    1. Create a new Rmd with the following contents:
    ---
    title: "No y"
    ---
    
    ```{r first}
    y
    ```
    
    ```{r second}
    x <- 1
    x
    ```
    
    1. Clear out history in History Pane.
    2. Restart R: Session -> Restart R
    3. Run the first chunk.
      • The message Error: object 'y' not found, as expected.
      • The line y appears in the History Pane.
    4. In the Console Pane, use the Up arrow.
      • Nothing happens
    5. Repeat: In the Console Pane, use the Up arrow.
      • Nothing happens
    6. Run the second chunk.
      • Runs successfully.
    7. In the Console Pane, use the Up arrow.
      • The second chunk's commands show up, but so does the previous chunks error-line
    > y
    x <- 1
    x
    

    Occurs in RStudio Desktop 2025.5.1.508 on Windows 11 and RStudio Server 2025.5.1.50 on Ubuntu 24 via Edge on Windows 11.

  10. self-assigned this
    on May 28, 2025
  11. ronblum commented on May 30, 2025

    @ronblum
    Contributor

    Verified in RStudio Desktop 2025.05.1+512 on Windows 11.

    Also added this test:

    ```{r third}
    a <- 83
    b <- 112
    m
    c <- 12
    d <- 9003
    ```
    

    Running the chunk: The first two lines will execute successfully, with failure on the third. Clicking on the up-arrow in the console will show these three commands as a block, up to the failed line.

    Image

    QA note: ref: #3520

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions