R devtools无法安装-Ubuntu 20.04-"pkgload"的软件包或名称空间加载失败 [英] R devtools unable to install - Ubuntu 20.04 - package or namespace load failed for ‘pkgload’

查看:217
本文介绍了R devtools无法安装-Ubuntu 20.04-"pkgload"的软件包或名称空间加载失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常渴望使用 install.packages("devtools").但是它始终会因该错误而失败

I am pretty desperate to install.packages("devtools"). However it allways fails with this error

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’

我试图解决的问题:

  1. 添加 dependencies = T 参数
  2. 遵循hadley wickham在github上的建议->更新rlang包
  3. 尝试运行 install.packages("pkgload")会导致几乎完全相同的错误(请参见下文)
  4. 完全删除R并重新安装
  5. 另外安装以下软件包:
    • r-base-dev
    • r-cran-devtools
    • r推荐
  1. Add the dependencies = T argument
  2. Following a suggestion by hadley wickham on github -> update rlang package
  3. Try to run install.packages("pkgload") resulting in nearly exactly the same error (see below)
  4. Completely removing R and reinstalling it
  5. Additionally installing package following packages:
    • r-base-dev
    • r-cran-devtools
    • r-recommended

install.packages("pkgload")错误

Error of install.packages("pkgload")

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

我更深入地研究了 pkgload (其中至少我希望是问题的唯一原因).我将检查是否手动(重新)安装所有导入,并从pkgload的CRAN页面建议解决该问题.

I digged even deeper to the pkgload (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.

导入:desc,方法,pkgbuild,rlang,rprojroot,rstudioapi,utils,withr
建议: bitops,covr,Rcpp,testthat

Imports: desc, methods, pkgbuild, rlang, rprojroot, rstudioapi, utils, withr
Suggests: bitops, covr, Rcpp, testthat


我的 sessionInfo()输出:

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

我仍然不相信在ubuntu20上安装devtools是不可能的
但是在这一点上,我会吸尽稻草

I still refuse to belief that it is impossibe to install devtools on ubuntu20
However at this point I take any straw

简而言之,为我解决的问题是之前安装了testthat软件包.感谢 rui-barradas

In short what fixed the issue for me was installing testthat package before. Thanks to comment by rui-barradas

install.packages("testthat") 
install.packages("pkgload") 
install.packages("devtools") 

推荐答案

我也在Ubuntu 20.04上,但运行的是R 4.0.0.

当尝试安装软件包时,如果它依赖于R 4.0.0之前安装的另一个软件包,则会收到错误消息,并且安装失败.即使我在对 install.packages 的调用中设置了 dependencies = TRUE ,也会发生这种情况.

When trying to install a package, if it depends on another that was installed prior to R 4.0.0 I get an error message and the installation fails. This happens even if I set dependencies = TRUE in the call to install.packages.

示例:命令是

install.packages('pkgload')

我省略了第一行输出,说文件已下载.然后,相关部分.

I omit the first output lines, saying that the file was downloaded. Then, the relevant part.

  • 正在安装 source 软件包"pkgload" ...
    **软件包"rcmdcheck"已成功解压,并检查了MD5总和
    **使用分阶段安装
    ** R
    **进行字节编译并准备用于延迟加载的软件包错误:R 4.0.0之前安装的软件包"testthat":请重新安装
    执行停止错误:"pkgload"包
  • 的延迟加载失败
  • 删除"/usr/local/lib/R/site-library/pkgload"
  • 在install.packages中恢复先前的"/usr/local/lib/R/site-library/pkgload"警告:安装了"pkgload"软件包非零退出状态下载的源程序包位于
    ‘/tmp/RtmpVxpbs0/downloaded_pa​​ckages’
  • installing source package ‘pkgload’ ...
    ** package ‘rcmdcheck’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** byte-compile and prepare package for lazy loading Error: package ‘testthat’ was installed before R 4.0.0: please re-install it
    Execution halted ERROR: lazy loading failed for package ‘pkgload’
  • removing ‘/usr/local/lib/R/site-library/pkgload’
  • restoring previous ‘/usr/local/lib/R/site-library/pkgload’ Warning in install.packages : installation of package ‘pkgload’ had non-zero exit status The downloaded source packages are in
    ‘/tmp/RtmpVxpbs0/downloaded_packages’

正确的方法.
安装软件包 pkgload 的正确方法是运行序列

Correct way.
The right way of installing package pkgload was to run the sequence

install.packages('testthat')
install.packages('pkgload')

问题已解决.

注意,对于其他软件包,已经碰巧看到这是一个递归问题.想象一下,软件包 testthat 依赖于(不是)依赖于R 4.0.0之前安装的另一个软件包.

Note that with other packages, it already happened to see this be a recursive issue. Imagine that package testthat depended (which it does not) on another package installed prior to R 4.0.0.

烦人但可以解决.

sessionInfo()  
#R version 4.0.0 (2020-04-24)  
#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=pt_PT.UTF-8       LC_NUMERIC=C                
#[3] LC_TIME=pt_PT.UTF-8        LC_COLLATE=pt_PT.UTF-8      
# [5] LC_MONETARY=pt_PT.UTF-8    LC_MESSAGES=pt_PT.UTF-8     
# [7] LC_PAPER=pt_PT.UTF-8       LC_NAME=C                   
# [9] LC_ADDRESS=C               LC_TELEPHONE=C                
#[11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C           
#  
#attached base packages:  
#[1] stats     graphics  grDevices utils     datasets   
#[6] methods   base       
#  
#other attached packages:  
#[1] rvest_0.3.5       xml2_1.3.2        data.table_1.12.8  
#
#loaded via a namespace (and not attached):  

这篇关于R devtools无法安装-Ubuntu 20.04-"pkgload"的软件包或名称空间加载失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆