简体   繁体   English

R 开发工具无法安装 - Ubuntu 20.04 - package 或“pkgload”的命名空间加载失败

[英]R devtools unable to install - Ubuntu 20.04 - package or namespace load failed for ‘pkgload’

I am pretty desperate to install.packages("devtools") .我非常渴望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’

Things I tried to fix this:我试图解决的问题:

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

Error of install.packages("pkgload") 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

I digged even deeper to the pkgload (which at least I hope is the only reason for the problem).我对pkgload进行了更深入的研究(至少我希望这是问题的唯一原因)。 I will check if manually (re)installing all imports and suggests from the CRAN page of pkgload does solve it.我将检查是否手动(重新)安装所有导入并从 pkgload 的 CRAN 页面提出的建议确实解决了它。

Imports: desc, methods, pkgbuild, rlang, rprojroot, rstudioapi, utils, withr导入: desc、methods、pkgbuild、rlang、rprojroot、rstudioapi、utils、withr
Suggests: bitops, covr, Rcpp, testthat建议: bitops、covr、Rcpp、testthat


My sessionInfo() output: 我的sessionInfo() output:

 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

I still refuse to belief that it is impossibe to install devtools on ubuntu20我仍然拒绝相信在 ubuntu20 上安装 devtools 是不可能的
However at this point I take any straw然而在这一点上,我采取了任何稻草

Solution Edit:解决方案编辑:

In short what fixed the issue for me was installing testthat package before.简而言之,为我解决问题的是之前安装了 package 的测试。 Thanks to comment by rui-barradas感谢rui-barradas 的评论

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

I am also on Ubuntu 20.04 but running R 4.0.0.我也在 Ubuntu 20.04 但运行 R 4.0.0。

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.尝试安装 package 时,如果它依赖于在 R 4.0.0 之前安装的另一个,我会收到一条错误消息并且安装失败。 This happens even if I set dependencies = TRUE in the call to install.packages .即使我在install.packages调用中设置dependencies = TRUE也会发生这种情况。

Example: The command was示例:命令是

install.packages('pkgload')

I omit the first output lines, saying that the file was downloaded.我省略了第一个 output 行,表示文件已下载。 Then, the relevant part.然后,相关部分。

  • installing source package 'pkgload'...安装package 'pkgload'...
    ** package 'rcmdcheck' successfully unpacked and MD5 sums checked ** package 'rcmdcheck' 成功解压并检查 MD5 和
    ** using staged installation ** 使用分阶段安装
    ** R ** R
    ** byte-compile and prepare package for lazy loading Error: package 'testthat' was installed before R 4.0.0: please re-install it ** 字节编译并准备 package 用于延迟加载错误:package 'testthat' 是在 R 4.0.0 之前安装的,请重新安装它:
    Execution halted ERROR: lazy loading failed for package 'pkgload'执行停止错误:package 'pkgload' 的延迟加载失败
  • removing '/usr/local/lib/R/site-library/pkgload'删除 '/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恢复以前的 '/usr/local/lib/R/site-library/pkgload' install.packages 中的警告:安装 package 'pkgload' 的退出状态非零 下载的源包在
    '/tmp/RtmpVxpbs0/downloaded_packages' '/tmp/RtmpVxpbs0/downloaded_packages'

Correct way.正确的方式。
The right way of installing package pkgload was to run the sequence安装 package pkgload的正确方法是运行序列

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

and the problem was solved.问题就解决了。

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.想象一下testthat依赖于(它不依赖于)在 R 4.0.0 之前安装的另一个 package。

Annoying but solvable.烦人但可以解决。

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):  

I had the same problems, and the solution was, at least in my case, Ubuntu 20.04.1 LTS (Focal Fossa) + R 4.0.2:我遇到了同样的问题,至少在我的情况下,解决方案是 Ubuntu 20.04.1 LTS (Focal Fossa) + R 4.0.2:

First (from terminal), install:首先(从终端),安装:

Step 1: sudo apt-get update -y第 1 步:sudo apt-get update -y
Step 2: sudo apt-get install -y libxml2-dev第 2 步:sudo apt-get install -y libxml2-dev

Then from RStudio (setRepositories first, and choose 8 repositories) and install both packages:然后从 RStudio (首先设置存储库,并选择 8 个存储库)并安装两个包:

  1. Install xml2 package安装xml2 package

  2. install devtools安装开发工具

And works for me.并为我工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未能在 Ubuntu 20.04 焦距中安装 R - failed to install R in Ubuntu 20.04 focal 'sf'(R包)的命名空间加载失败,无法加载共享对象 - namespace load failed for ‘sf’ (R package) , unable to load shared object 安装 devtools 时出现错误:“'devtools' 的包或命名空间加载失败” - Error: "package or namespace load failed for ‘devtools’" when installing devtools 在 ubuntu VM 中安装 devtools package - Install devtools package in ubuntu VM R:“mxnet”的命名空间加载失败:package“mxnet”是在 R 4.0.0 之前安装的:请重新安装它 - R: namespace load failed for ‘mxnet’: package ‘mxnet’ was installed before R 4.0.0: please re-install it 无法在 MacOS Mojave 10.14.6、R 3.5.1 上安装 devtools 包 - Unable to install devtools package on MacOS Mojave 10.14.6, R 3.5.1 无法为安装在linux redhat服务器上的R studio安装Devtools软件包 - Unable to install Devtools package for R studio mounted on linux redhat server 为什么我的R devtools软件包加载失败? - Why has my R devtools package load failed? 无法在R 3.1.2中安装devtools - Failed to install devtools in R 3.1.2 R:库错误(affy):错误:package 或 dyn.load(文件,DLLpath = DLLpath,...)中“affy”的命名空间加载失败:无法加载共享对象 - R: Error in library(affy): Error: package or namespace load failed for ‘affy’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared objec
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM