title: Change default loading of `shiny` to specific `.libPaths()` on ShinyServer
body: <h1>Problem</h1>
  
  <p>I'm deploying a Shiny App on a shiny server maintained by my university, and there are many <code>.libPaths()</code> that contain different versions of packages.  </p>
  
  <pre><code>&gt; .libPaths()
  [1] "/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4"
  [2] "/nfs/admin/software/xenial/system-gcc/R_libs"      
  [3] "/usr/local/lib/R/site-library"                     
  [4] "/usr/lib/R/site-library"                           
  [5] "/usr/lib/R/library"  
  </code></pre>
  
  <p>When my shiny app boots up, <code>shiny</code> is loaded by default from <code>.libPaths()[2]</code>, which then imports <code>R6</code> <strong>V.2.2.1</strong>, also from this path. </p>
  
  <h1>However, my code depends on <code>R6</code> <strong>>= V.2.2.2</strong>, which I have in <code>.libPaths()[1].</code></h1>
  
  <p>It would be simple enough to have my SysAdmin update <code>R6</code> in <code>.libPaths()[2]</code>, but they cannot because other people's apps depend on the libraries on that path, and we don't want to break those.</p>
  
  <hr>
  
  <h1>I've tried:</h1>
  
  <ol>
  <li><p>detaching <code>R6</code> and loading it from <code>.libPaths()[1]</code>  </p>
  
  <pre><code>detach("package:R6", unload=TRUE, force = TRUE, character.only = TRUE)
  library(R6, lib.loc = "/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4")  
  </code></pre></li>
  <li><p>detaching <code>shiny</code> and loading it from <code>.libPaths()[1]</code>  </p>
  
  <pre><code>detach("package:shiny", unload=TRUE, force = TRUE, character.only = TRUE)
  library(shiny, lib.loc = "/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4")  
  </code></pre></li>
  <li><p>setting my <code>.libPaths()</code> from the start in the <code>global.R</code> file to only include the path I want.  </p>
  
  <pre><code>.libPaths(.libPaths()[1])
  </code></pre></li>
  <li><p>adding an <code>etc</code> folder under <code>"/zeolite/rpauloo/R"</code> that contains the following <code>Rprofile.site</code> file (<a href="https://stackoverflow.com/questions/15170399/change-r-default-library-path-using-libpaths-in-rprofile-site-fails-to-work">advice from here</a>):  </p>
  
  <pre><code>.First &lt;- function(){
    .libPaths("/zeolite/rpauloo/R/x86_64-pc-linux-gnu-library/3.4")
  }
  </code></pre></li>
  </ol>
  
  <p>None of these approaches work. Why? </p>
  
  <ol>
  <li><code>R6</code> is an attached package, so it can't be unloaded.  </li>
  <li>not sure why unloading/reloading shiny doesn't work  </li>
  <li>Shiny Server loads <code>shiny</code> from <code>.libPaths()[2]</code> to begin with, before the <code>global.R</code> file is sourced, so setting <code>libPaths()</code> doesn't help.  </li>
  <li>the <code>Rprofile.site</code> file is probably in the wrong directory, but putting it in an admin directory will mess with other apps    </li>
  </ol>
  
  <hr>
  
  <h1>Question</h1>
  
  <h3>How can I configure my shiny app to load <code>shiny</code> from a specific <code>.libPath</code> on startup?</h3>
  
  <p>Or have I mis-conceptualized the problem? Is there another way to go about this?</p>