You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

M1芯片Mac使用renv安装R包时无法找到arm64二进制文件

M1芯片MacBook的renv环境R包安装故障

问题核心

搭载ARM64架构M1芯片的MacBook,通过renv::init()初始化环境后,使用install.packages()或renv::install()安装R包时频繁失败,核心原因是环境未正确识别ARM64架构,无法从CRAN获取对应二进制包。

安装png包的错误示例

执行renv::install('png')时出现以下错误:

> 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]

二进制包安装验证

本机可正常安装二进制包,手动从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

当前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            

内容的提问来源于stack exchange,提问作者PianoEntropy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 01:25:02