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

骁龙X 12核Windows11电脑部署Ruby on Rails失败求助

在Windows 11(骁龙X1E80100处理器)部署Ruby on Rails时安装psych 5.1.2失败的解决方法

问题详情

在搭载Snapdragon(R) X 12核X1E80100处理器的Windows 11电脑上部署Ruby on Rails,按步骤安装Ruby、重启、安装rails gem后,执行rails new创建项目失败。系统日志显示找不到yaml.h,无法安装psych 5.1.2,手动安装该gem也失败。

错误日志详情

Installing psych 5.1.2 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

...and later...

An error occurred while installing psych (5.1.2), and Bundler cannot continue.

In Gemfile:

debug was resolved to 1.9.2, which depends on

irb was resolved to 1.14.0, which depends on

rdoc was resolved to 6.7.0, which depends on

psych

run bundle lock --add-platform=x86_64-linux

Fetching gem metadata from https://rubygems.org/...........

Resolving dependencies...

Writing lockfile to C:/Users/TomMo/Code/Journaley/Gemfile.lock

run bundle binstubs bundler
Could not find debug-1.9.2, irb-1.14.0, rdoc-6.7.0, psych-5.1.2 in locally

PATH=".;C:/Ruby32-x64/lib;C:\Ruby32-x64\bin;C:\Ruby32-x64\msys64\ucrt64\bin;C:\Ruby32-x64\msys64\usr\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Ruby32-x64\bin;C:\Users\TomMo\AppData\Local\Microsoft\WindowsApps;C:\Users\TomMo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\TomMo\.dotnet\tools" x86_64-w64-mingw32-pkg-config --exists yaml-0.1
package configuration for yaml-0.1 is not found
find_header: checking for yaml.h... -------------------- no

PATH=".;C:/Ruby32-x64/lib;C:\Ruby32-x64\bin;C:\Ruby32-x64\msys64\ucrt64\bin;C:\Ruby32-x64\msys64\usr\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Ruby32-x64\bin;C:\Users\TomMo\AppData\Local\Microsoft\WindowsApps;C:\Users\TomMo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\TomMo\.dotnet\tools" "gcc -o conftest.exe -IC:/Ruby32-x64/include/ruby-3.2.0/x64-mingw-ucrt -IC:/Ruby32-x64/include/ruby-3.2.0/ruby/backward -IC:/Ruby32-x64/include/ruby-3.2.0 -I. -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -DYAML_DECLARE_STATIC -O3 -fno-fast-math -fstack-protector-strong conftest.c  -L. -LC:/Ruby32-x64/lib -L. -pipe -s -fstack-protector-strong -Wl,--no-as-needed  -m64   -lx64-ucrt-ruby320  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi -lbcrypt  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return !!argv[argc];
8: }
/* end */

PATH=".;C:/Ruby32-x64/lib;C:\Ruby32-x64\bin;C:\Ruby32-x64\msys64\ucrt64\bin;C:\Ruby32-x64\msys64\usr\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\dotnet\;C:\Ruby32-x64\bin;C:\Users\TomMo\AppData\Local\Microsoft\WindowsApps;C:\Users\TomMo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\TomMo\.dotnet\tools" "gcc -IC:/Ruby32-x64/include/ruby-3.2.0/x64-mingw-ucrt -IC:/Ruby32-x64/include/ruby-3.2.0/ruby/backward -IC:/Ruby32-x64/include/ruby-3.2.0 -I. -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -DYAML_DECLARE_STATIC -O3 -fno-fast-math -fstack-protector-strong -m64  -c conftest.c"
conftest.c:5:10: fatal error: yaml.h: No such file or directory
    5 | #include <yaml.h>
      |          ^~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <yaml.h>
/* end */

--------------------

解决步骤

方法1:安装libyaml依赖(针对MSYS2环境)

  • 打开Ruby安装目录下的MSYS2终端(比如C:\Ruby32-x64\msys64\ucrt64.exe)
  • 执行以下命令安装libyaml:
    pacman -S mingw-w64-ucrt-x86_64-libyaml
    
  • 安装完成后,回到Windows命令提示符或PowerShell,重新尝试安装psych:
    gem install psych -v 5.1.2
    
  • 再执行rails new创建项目

方法2:指定psych使用系统自带的yaml

  • 尝试安装psych时指定libyaml路径:
    gem install psych -v 5.1.2 -- --with-libyaml-dir="C:\Ruby32-x64\msys64\ucrt64"
    
  • 若上述命令无效,直接跳过原生扩展编译:
    gem install psych -v 5.1.2 --no-build-extensions
    

方法3:更换Ruby版本

如果以上方法都无效,降级Ruby到3.1.x版本,该版本的psych依赖兼容性更好,无需额外安装libyaml即可正常编译。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 04:00:55