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

Windows 10下Ruby安装Gem原生扩展失败求助

Troubleshooting Ruby Native Extension Installation Issues on Windows 10 (Ruby 2.3.3)

Hey there, let's work through this Ruby native extension headache on Windows 10 together! First, I'll recap what you've already tried to avoid repeating steps:

  • Using a DevKit compatible with Ruby 2.3.3
  • Running devkitvars.bat to set up environment variables
  • Installing GCC
  • Attempting installs via bundle install and direct gem install <gem name>

Here are targeted steps to dig deeper and fix the issue:

1. Double-check DevKit binding to your Ruby installation

Even if you ran devkitvars.bat, sometimes the DevKit doesn't properly attach to your Ruby setup. Let's reset that:

  • Close all open command prompts/terminals
  • Open a new Administrator command prompt
  • Navigate to your DevKit folder (e.g., C:\RubyDevKit)
  • Run ruby dk.rb init to generate the config.yml file
  • Open config.yml in a text editor—make sure your Ruby 2.3.3 path is listed with forward slashes (like - C:/Ruby23-x64)
  • Run ruby dk.rb install to bind DevKit to your Ruby instance
  • Re-run devkitvars.bat to reload environment variables

2. Confirm GCC version compatibility

Ruby 2.3.3 plays best with GCC 4.7.2 (the version bundled with the official RubyInstaller DevKit for 2.3.x). Newer GCC versions often cause compatibility issues:

  • Run gcc --version in your prompt to check the version
  • If it's not 4.7.2, uninstall the standalone GCC you installed and rely on the one in your DevKit's mingw\bin directory—devkitvars.bat should already add this to your PATH

3. Force the gem installer to use DevKit's compiler

Sometimes the gem setup doesn't auto-detect the DevKit's GCC. Explicitly set the compiler paths before installing:

set CC=C:\RubyDevKit\mingw\bin\gcc.exe
set CXX=C:\RubyDevKit\mingw\bin\g++.exe
gem install <gem name>

(Replace C:\RubyDevKit with your actual DevKit installation path)

4. Add missing system library paths

Some native gems require additional headers/libraries (like OpenSSL, libxml2) that might not be in your default PATH. Add these paths manually:

set INCLUDE=C:\RubyDevKit\mingw\include;%INCLUDE%
set LIB=C:\RubyDevKit\mingw\lib;%LIB%

Then retry the gem installation.

5. Update Bundler and get verbose error details

Outdated Bundler versions can mess with native extension builds on Windows. First update it:

gem update bundler

Then run bundle install with verbose output to see exactly where the compilation fails:

bundle install --verbose

The verbose logs will show specific errors (like missing headers or invalid flags) that point to the root problem.

6. Force source compilation with --platform=ruby

Sometimes Windows-specific gem builds are broken or unavailable. Compile the gem from source directly:

gem install <gem name> --platform=ruby

If none of these steps work, sharing the exact error message you see during installation would help narrow things down even further!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 08:13:45