Fedora 43环境下安装tidyverse R包失败求助
解决Fedora 43下安装tidyverse R包失败的问题
问题背景
在全新安装的Fedora 43(KDE Plasma桌面)环境中,未使用RStudio,尝试安装tidyverse R包数小时未果。此前在Fedora新系统安装该包时,只需安装xml2、curl、openssl、libuv、libpng、libjpeg、libtiff、libwebp、fontconfig、freetype2这些系统依赖即可正常安装,但此次已安装所有提示依赖仍失败,错误指向rmarkdown安装时xfun包的兼容性问题。
错误信息
执行install.packages("tidyverse")后出现以下错误:
> install.packages("tidyverse") Installing package into '/home/oliver/R/x86_64-redhat-linux-gnu-library/4.5' (as 'lib' is unspecified) --- Please select a CRAN mirror for use in this session --- also installing the dependencies 'rmarkdown', 'reprex' trying URL 'https://cloud.r-project.org/src/contrib/rmarkdown_2.31.tar.gz' trying URL 'https://cloud.r-project.org/src/contrib/reprex_2.1.1.tar.gz' trying URL 'https://cloud.r-project.org/src/contrib/tidyverse_2.0.0.tar.gz' * installing *source* package 'rmarkdown' ... ** this is package 'rmarkdown' version '2.31' ** package 'rmarkdown' successfully unpacked and MD5 sums checked ** using staged installation ** R ** inst ** byte-compile and prepare package for lazy loading Error: object 'attr' is not exported by 'namespace:xfun' Execution halted ERROR: lazy loading failed for package 'rmarkdown' * removing '/home/oliver/R/x86_64-redhat-linux-gnu-library/4.5/rmarkdown' ERROR: dependency 'rmarkdown' is not available for package 'reprex' Perhaps try a variation of: install.packages('rmarkdown') * removing '/home/oliver/R/x86_64-redhat-linux-gnu-library/4.5/reprex' ERROR: dependency 'reprex' is not available for package 'tidyverse' Perhaps try a variation of: install.packages('reprex') * removing '/home/oliver/R/x86_64-redhat-linux-gnu-library/4.5/tidyverse' The downloaded source packages are in '/tmp/Rtmp0GMiOa/downloaded_packages' Warning messages: 1: In install.packages("tidyverse") : installation of package 'rmarkdown' had non-zero exit status 2: In install.packages("tidyverse") : installation of package 'reprex' had non-zero exit status 3: In install.packages("tidyverse") : installation of package 'tidyverse' had non-zero exit status
解决方案
这个错误的核心是xfun包版本不兼容或未正确安装,导致rmarkdown无法调用其导出的attr函数。按以下步骤解决:
更新/重装xfun包
打开R终端执行:remove.packages("xfun") install.packages("xfun", dependencies = TRUE)单独安装rmarkdown
xfun安装完成后,单独安装rmarkdown:install.packages("rmarkdown", dependencies = TRUE)安装tidyverse
待rmarkdown安装成功后,再次执行:install.packages("tidyverse")确认系统依赖完整性
再检查一遍系统层面的依赖是否齐全,在终端执行:sudo dnf install xml2-devel curl-devel openssl-devel libuv-devel libpng-devel libjpeg-turbo-devel libtiff-devel libwebp-devel fontconfig-devel freetype-devel
补充处理
如果上述步骤无效,可清理R包缓存后重试:
unlink("/tmp/Rtmp0GMiOa/downloaded_packages/*") install.packages("tidyverse")
内容的提问来源于stack exchange,提问作者o_prioli
相关产品推荐
相关产品推荐

