title: Rstudio holds Excelfile permission - XLconnect
body: <p>Since I updated RStudio last day I cannot get Rstudio to drop it's hold on my excelfiles.</p>
  <p>I've tried the following to no avail:</p>
  <pre><code>  unlink(fileName, recursive = TRUE)
    file.info(fileName)
    file.remove(fileName)
  </code></pre>
  <p>file.info gives the following:</p>
  <pre><code>size 2383465
  isdir FALSE
  mode 666
  mtime 2020-08-06 11:02:03
  ctime 2020-06-16 13:00:22
  atime 2020-08-06 10:40:30
  exe no
  </code></pre>
  <p>RStudio is installed by an administrator but I personally don't hold admin-privileges in my organization. file.remove isn't permitted even with unlink (but it's not a dir so...). And I don't really want to remove it, just get Rstudio to drop the hold. The file will be modified in Excel (and saved, which is not permitted since RStudio holds it).</p>
  <p>UPDATE:</p>
  <p>I guess this is a bug, so all my googling have found no solution so far. One workaround I guess would be able to fix this is if I could programmatically re-initialize the JVM-instance. (for instance,   <code>.rs.restartR()</code> do drop the R:s hold on the file)</p>
  <p>UPDATE 2 :</p>
  <p>The exact same error happens with the openxlsx-package, which is not dependant on Java so the problem is probably with R.</p>
  <pre><code>R version 3.6.3 (2020-02-29)
  Platform: x86_64-w64-mingw32/x64 (64-bit)
  Running under: Windows 10 x64 (build 18362)
  
  Matrix products: default
  
  locale:
  [1] LC_COLLATE=Swedish_Finland.1252  LC_CTYPE=Swedish_Finland.1252    LC_MONETARY=Swedish_Finland.1252
  [4] LC_NUMERIC=C                     LC_TIME=Swedish_Finland.1252 
  </code></pre>
  <p>UPDATE 3:</p>
  <p>Still no breakthrough here, I've solved the lock with a bit of hacky-code but it solves the immediate problem atleast:</p>
  <pre><code>  .rs.restartR()
    source(&quot;~/.Rprofile&quot;)
  </code></pre>
  <p>UPDATE 4:</p>
  <p>If I do this:</p>
  <pre><code>library(XLConnect)
  
  wb &lt;- loadWorkbook(&quot;Cars.xlsx&quot;, create = TRUE)
  createSheet(wb, &quot;Data&quot;)
  writeWorksheet(wb, cars, &quot;Data&quot;)
  saveWorkbook(wb)
  </code></pre>
  <p>The first time a open the file, I can save without closing the R-session. If I do that, open the Excel-file and save, and then re-run the above code my R-session hold the permission lock. So it has something within the scope the file is saved.</p>
  <p>UPDATE 5:</p>
  <p>This is now an open Issue, probably Windows-only bug:</p>
  <p><a href="https://github.com/miraisolutions/xlconnect/issues/110" rel="nofollow noreferrer">Github - XLconnect</a></p>