title: R devtools unable to install - Ubuntu 20.04 - package or namespace load failed for ‘pkgload’
body: <p>I am pretty desperate to <code>install.packages("devtools")</code>.
  However it allways fails with this error</p>
  
  <pre><code>Error: .onLoad failed in loadNamespace() for 'pkgload', details:
    call: readRDS(nsInfoFilePath)
    error: error reading from connection
  Execution halted
  ERROR: lazy loading failed for package ‘devtools’
  * removing ‘/home/bjoern/R/x86_64-pc-linux-gnu-library/3.6/devtools’
  </code></pre>
  
  <p>Things I tried to fix this:</p>
  
  <ol>
  <li>Add the <code>dependencies = T</code> argument</li>
  <li>Following a suggestion by hadley wickham on github -> update rlang package</li>
  <li>Try to run <code>install.packages("pkgload")</code> resulting in nearly exactly the same error (see below)</li>
  <li>Completely removing R and reinstalling it</li>
  <li>Additionally installing package following packages:
  
  <ul>
  <li>r-base-dev</li>
  <li>r-cran-devtools</li>
  <li>r-recommended</li>
  </ul></li>
  <li>Updated all packages update.packages(ask = FALSE, checkBuilt = TRUE)</li>
  </ol>
  
  <p>Error of install.packages("pkgload")</p>
  
  <pre><code>Error: package or namespace load failed for ‘pkgload’:
   .onLoad failed in loadNamespace() for 'pkgload', details:
    call: readRDS(nsInfoFilePath)
    error: error reading from connection
  Error: loading failed
  Execution halted
  ERROR: loading failed
  </code></pre>
  
  <p>I digged even deeper to the <a href="https://cran.r-project.org/web/packages/pkgload/index.html" rel="nofollow noreferrer">pkgload</a> (which at least I hope is the only reason for the problem). I will check if manually (re)installing all imports and suggests from the CRAN page of pkgload does solve it.</p>
  
  <blockquote>
    <p><strong>Imports:</strong>  desc, methods, pkgbuild, rlang, rprojroot, rstudioapi,
    utils, withr <br><strong>Suggests:</strong>    bitops, covr, Rcpp, testthat</p>
  </blockquote>
  
  <p><hr/>
  My <code>sessionInfo()</code> output:</p>
  
  <pre><code>R version 3.6.3 (2020-02-29)
  Platform: x86_64-pc-linux-gnu (64-bit)
  Running under: Ubuntu 20.04 LTS
  
  Matrix products: default
  BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
  LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
  
  locale:
   [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
   [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=en_US.UTF-8    
   [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8   
   [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
   [9] LC_ADDRESS=C               LC_TELEPHONE=C            
  [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  loaded via a namespace (and not attached):
  [1] compiler_3.6.3 tools_3.6.3
  </code></pre>
  
  <p><strong>I still refuse to belief that it is impossibe to install devtools on ubuntu20</strong><br>
  However at this point I take any straw</p>
  
  <h1>Solution Edit:</h1>
  
  <p>In short what fixed the issue for me was installing testthat package before. Thanks to comment by <a href="https://stackoverflow.com/users/8245406/rui-barradas">rui-barradas</a></p>
  
  <pre><code>install.packages("testthat") 
  install.packages("pkgload") 
  install.packages("devtools") 
  </code></pre>