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

Fastlane执行slather步骤报错:nokogiri要求Ruby版本≥2.3.0

Troubleshooting 'nokogiri requires Ruby version >= 2.3.0' Error in Slather/Fastlane for Swift SonarQube Setup

I’ve dealt with similar environment mismatch headaches before—even when your system Ruby version clearly meets the requirement, tooling like Fastlane can sometimes pull from a different context. Here are practical, step-by-step fixes to get your fastlane metrics command working again:

1. Confirm Which Ruby Version Fastlane Is Actually Using

Your system Ruby might be 2.6.3, but Fastlane could be tapping into a separate Ruby environment (from rbenv, rvm, or an unmanaged gem set). Run this to check:

fastlane env

Look for the Ruby Version line in the output. If it doesn’t match 2.6.3, switch to your project’s correct Ruby version:

  • For rbenv users: rbenv local 2.6.3
  • For rvm users: rvm use 2.6.3

2. Use Bundler to Lock Dependencies (Most Reliable Fix)

Bundler ensures all gems (slather, nokogiri, and Fastlane itself) use versions compatible with your Ruby environment. Here’s how to set it up:

  1. Create a Gemfile in your project root with this content:
    source "https://rubygems.org"
    gem "fastlane"
    gem "slather"
    
  2. Install the locked dependencies:
    bundle install
    
  3. Run Fastlane through Bundler to enforce the correct environment:
    bundle exec fastlane metrics
    

3. Reinstall Nokogiri and Slather to Fix Corrupted Installs

Sometimes gem installations get corrupted, even with the right Ruby version. Try a clean reinstall:

# Uninstall existing versions
gem uninstall nokogiri slather

# Reinstall nokogiri with system libraries (avoids macOS-specific build issues)
gem install nokogiri --use-system-libraries
gem install slather

If nokogiri still fails to install, make sure you have Xcode Command Line Tools up to date:

xcode-select --install

4. Update Xcode Command Line Tools

Outdated XCLT can cause hidden compatibility issues with Ruby gems like nokogiri. Verify your version:

xcode-select --version

If it doesn’t match your current Xcode version, update it via the command above or through Xcode’s Preferences > Locations tab.

5. Clear Cached Artifacts

Old build caches or gem leftovers might be interfering. Clean them up with:

# Clear Fastlane's build cache
fastlane clean_build_cache

# Remove outdated gem versions
gem cleanup

Work through these steps in order—most of the time, either verifying the Ruby environment or using Bundler will resolve this confusing version mismatch error.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:33:46