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

部署R语言Plumber API至Posit Connect时遇arrow包安装错误

解决Posit Connect部署Plumber API时arrow包的C++17编译错误

几个可行的解决方向

1. 检查服务器编译器配置

  • 确认Posit Connect服务器是否安装了支持C++17的编译器(比如GCC 7+、Clang 5+),没有的话需要联系服务器管理员安装对应版本。
  • 若服务器已有编译器但R未识别,可在.Rprofile中添加环境变量强制指定:
    Sys.setenv(CXX17 = "g++-11") # 根据服务器实际编译器版本调整,比如g++-9
    Sys.setenv(CXX17STD = "-std=c++17")
    

2. 改用arrow二进制包安装

  • 源码编译需要C++17,直接安装预编译的二进制包可绕过该问题,在requirements.txt或部署脚本中添加:
    install.packages("arrow", type = "binary")
    
    注意:需确保Posit Connect使用的包源提供arrow二进制包,比如CRAN二进制镜像或Posit Package Manager。

3. 修正renv.lock配置

  • 打开renv.lock文件,找到arrow包条目,检查Source是否为Repository(二进制源),若为源码或GitHub源,修改为CRAN二进制源。
  • 本地重新生成lock文件时,先安装二进制版arrow再快照:
    renv::install("arrow", type = "binary")
    renv::snapshot()
    

4. 部署时强制使用二进制包

  • 在deployApp中添加参数,强制安装阶段使用二进制包:
    rsconnect::deployApp(
      appPrimaryDoc = "plumber_api_file.R",   
      appFiles = c("plumber_api_file.R", "requirements.txt", "renv.lock", ".Rprofile"),   
      contentCategory = "api",  
      appName = "some_plumber_api",
      args = c("--install-args='--binary'")
    )
    

补充提示

  • 本地运行正常是因为本地环境具备C++17编译器,而Posit Connect服务器环境可能缺少对应配置。
  • 若服务器无法升级编译器,可尝试降级arrow包,比如arrow 8.0.0及之前版本对C++标准要求较低。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 13:52:42