kevinushey / sourcetools

Tools for reading, tokenizing, and parsing R code.
MIT License
77 stars 3 forks source link

Error saving file after it's been tokenized #18

Closed webdevdufrain closed 7 years ago

webdevdufrain commented 7 years ago

Steps to recreate error:

  1. Using R, run the command tokenize_file() on an R file.
  2. Edit that file and try to save it.
  3. Error message persists and save fails each time. Only when R is shut down am I able to save the file.

I initally found this error whilst using RStudio, but without using RStudio I can still recreate the error:

  1. Tokenize the R file using R Command Line.
  2. Open the R file in a text editor and edit it and try to save it.
  3. Error message persists whilst R is open.

The error message reads Error: The requested operation cannot be performed on a file with the user-mapped section open.

After shutting down R, the file saves as normal.

Speculation: is the C code holding some lock on the tokenized file?

kevinushey commented 7 years ago

That sounds possible. Can you also provide your sessionInfo()?

kevinushey commented 7 years ago

I confirmed the issue on a Windows VM -- it should be resolved with https://github.com/kevinushey/sourcetools/commit/53ee2913f59aae601f9c372ce9d3622db9ede944. Thanks for reporting!

You can install the development version with:

devtools::install_github("kevinushey/sourcetools")
kevinushey commented 7 years ago

I'll submit a patch release of sourcetools to CRAN shortly to resolve this issue.