You need to enable JavaScript to run this app. Windows10安装recommendify gem失败:无法构建原生扩展,找不到hiredis.h
优惠活动
大模型
产品
解决方案
定价
更多

Windows10安装recommendify gem失败:无法构建原生扩展,找不到hiredis.h

错误原因

recommendify gem编译原生扩展依赖Redis的C客户端库hiredis,你的Windows环境缺少该库的头文件,所以安装时触发编译失败,报错fatal error: hiredis/hiredis.h: No such file or directory。

解决步骤
  • 首先确认你已经安装了Ruby对应的MSYS2开发工具链,如果你是用RubyInstaller安装的Ruby,运行安装包时勾选MSYS2 development toolchain选项即可完成安装。
  • 打开MSYS2终端,执行对应命令安装hiredis库:
    64位Ruby执行:
    pacman -S mingw-w64-x86_64-hiredis
    
    32位Ruby执行:
    pacman -S mingw-w64-i686-hiredis
    
  • 关闭MSYS2终端,打开普通CMD/PowerShell进入项目目录,执行命令单独安装recommendify:
    64位环境执行:
    gem install recommendify -v '0.3.8' -- --with-hiredis-dir=C:\msys64\mingw64
    
    32位环境执行:
    gem install recommendify -v '0.3.8' -- --with-hiredis-dir=C:\msys64\mingw32
    
  • 单独安装成功后,重新执行bundle install即可完成所有依赖安装。
备选方案

如果上述方案仍遇到兼容问题,推荐使用WSL2搭建Linux环境进行Ruby on Rails开发,Windows原生环境下大量带原生扩展的gem都容易出现编译依赖问题,Linux环境下开发体验会顺畅很多,后续遇到的环境兼容问题也会更少。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.21 07:24:04