title: Remove a library from .libPaths() permanently without Rprofile.site
body: <h1>How can I permanently remove a library in R?</h1>
  
  <pre><code>.libPaths()
  [1] "\\\\per-homedrive1.corp.riotinto.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
  [2] "C:/Program Files/R/R-2.15.2/library"                                            
  [3] "C:/Program Files/RStudio/R/library"     
  </code></pre>
  
  <p>The first item is my corporate "My Documents" folder, and the apostrophe in the path from my surname is causing all kinds of grief when using <code>R CMD INSTALL --build</code> on a package I'm making, not to mention issues using packages installed there when I'm offline from the network.</p>
  
  <p>I want to use <code>C:/Program Files/R/R-2.15.2/library</code> as the default instead, but I don't want to have to rely on an <code>Rprofile.site</code>.</p>
  
  <h2>What I've tried</h2>
  
  <pre><code>&gt; .libPaths(.libPaths()[2:3])
  &gt; .libPaths()
  [1] "C:/Program Files/R/R-2.15.2/library" "C:/Program Files/RStudio/R/library" 
  </code></pre>
  
  <p>That seems to work, but only until I restart my R session, and then I'm back to the original .libPaths() output...</p>
  
  <pre><code>Restarting R session...
  
  &gt; .libPaths()
  [1] "\\\\per-homedrive1.corp.riotinto.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
  [2] "C:/Program Files/R/R-2.15.2/library"                                            
  [3] "C:/Program Files/RStudio/R/library" 
  </code></pre>
  
  <p>I thought maybe <code>.libPaths()</code> was using <code>R_LIBS_USER</code> </p>
  
  <pre><code>&gt; Sys.getenv("R_LIBS_USER")
  [1] "//per-homedrive1.corp.riotinto.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
  </code></pre>
  
  <p>So I've tried to unset it using <code>Sys.unsetenv("R_LIBS_USER")</code> but it doesn't persist between sessions.</p>
  
  <h2>Additional Info</h2>
  
  <p>If it matters, here are some environment variables that might be relevant...</p>
  
  <pre><code>&gt; Sys.getenv("R_HOME")
  [1] "C:/PROGRA~1/R/R-215~1.2"
  &gt; Sys.getenv("R_HOME")
  [1] "C:/PROGRA~1/R/R-215~1.2"
  &gt; Sys.getenv("R_USER")
  [1] "//per-homedrive1.corp.riotinto.org/homedrive$/Tommy.O'Dell"
  &gt; Sys.getenv("R_LIBS_USER")
  [1] "//per-homedrive1.corp.riotinto.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
  &gt; Sys.getenv("R_LIBS_SITE")
  [1] ""
  </code></pre>
  
  <p>I've tried <code>Sys.unsetenv("R_LIBS_USER")</code> but this also doesn't stick between sessions</p>