install.packages() 找不到arm64 二进制文件

问题描述 投票:0回答:1

我一直在使用 M1 芯片(ARM64 架构)的 Macbook 上设置 renv,并在安装软件包时遇到问题。基本上,我认为问题在于我的设置无法正确检测我的 arm64 架构,并且无法在 CRAN 上找到正确的二进制文件。

我使用

renv::init()
启动我的环境,然后使用
install.packages()
renv::install()
安装软件包。许多软件包无法安装并出现错误消息,例如:

> renv::install('png')
# Downloading packages -------------------------------------------------------
- Downloading png from CRAN ...                 OK [file is up to date]
Successfully downloaded 1 package in 0.56 seconds.

The following package(s) will be installed:
- png [0.1-8]
These packages will be installed into "~/[***]/renv/library/R-4.3/aarch64-apple-darwin20".

Do you want to proceed? [Y/n]: y

# Installing packages --------------------------------------------------------
- Installing png ...                            FAILED


Error: Error installing package 'png':
===============================

* installing *source* package ‘png’ ...
** package ‘png’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using SDK: ‘MacOSX13.3.sdk’
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include    `libpng-config --cflags` -fPIC  -falign-functions=64 -Wall -g -O2  -c dummy.c -o dummy.o
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include    `libpng-config --cflags` -fPIC  -falign-functions=64 -Wall -g -O2  -c read.c -o read.o
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include    `libpng-config --cflags` -fPIC  -falign-functions=64 -Wall -g -O2  -c write.c -o write.o
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o png.so dummy.o read.o write.o -L/Users/[***]/miniconda3/lib -lpng16 -lz -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/[***]/renv/staging/1/00LOCK-png/00new/png/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘png’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/[***]/staging/1/00LOCK-png/00new/png/libs/png.so':
  dlopen(/Users/[***]/renv/staging/1/00LOCK-png/00new/png/libs/png.so, 0x0006): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: <B6F4C788-8DD4-3818-9093-3979F76F79B5> /Users/[***]/renv/staging/1/00LOCK-png/00new/png/libs/png.so
  Reason: tried: '/Library/Frameworks/R.framework/Resources/lib/libpng16.16.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-11.0.18+10/Contents/Home/lib/server/libpng16.16.dylib' (no such file)
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘[***]/renv/staging/1/png’
install of package 'png' failed [error code 1]

现在,我的 Mac 在安装表单源代码时出现问题,但我可以安装二进制文件。如果我直接从 CRAN 下载 arm64 二进制文件并手动安装它们,这不会出现任何问题。从二进制 URL 安装也没有问题。但是,如果我尝试

install.packages("png", type="binary")
,那么我会收到消息

Installing package into ‘/Users/[***]/renv/library/R-4.3/aarch64-apple-darwin20’
(as ‘lib’ is unspecified)

   package ‘png’ is available as a source package but not as a binary

Warning message:
package ‘png’ is not available as a binary package for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages

基本上,这对我来说表明安装程序没有检测到正确的体系结构并且无法找到二进制文件,但安装二进制文件没有问题。

我的R版本是

platform       aarch64-apple-darwin20      
arch           aarch64                     
os             darwin20                    
system         aarch64, darwin20           
status                                     
major          4                           
minor          3.0                         
year           2023                        
month          04                          
day            21                          
svn rev        84292                       
language       R                           
version.string R version 4.3.0 (2023-04-21)
nickname       Already Tomorrow            
r install.packages renv
1个回答
0
投票

您使用什么 CRAN 存储库?使用云镜像一切看起来都很好:

> options(repos = c(CRAN = "https://cloud.r-project.org"))
> install.packages("png", type = "binary")
Installing package into '/Users/kevin/Library/R/arm64/4.3/library'
(as 'lib' is unspecified)
trying URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.3/png_0.1-8.tgz'
Content type 'application/x-gzip' length 389013 bytes (379 KB)
==================================================
downloaded 379 KB
© www.soinside.com 2019 - 2024. All rights reserved.