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

Ruby 2.5.1安装bundler遇Gem::RemoteFetcher::FetchError,求彻底解决方案

Understanding the Bundler Install 403 Error & Permanent Fixes

Hey there, let's break down why you ran into that 403 Forbidden error and how to fix it for good.

Root Cause

The core issue here is that the http://gems.github.com source you're hitting is long deprecated and no longer functional. GitHub shut down its dedicated Gem hosting service years ago, migrating all official Gem hosting to the standard RubyGems registry at https://rubygems.org/.

Your Ruby 2.5.1 installation (which is a somewhat older version) likely still had this outdated source in its default configuration. When you tried to install Bundler, RubyGems attempted to fetch the gem spec from the defunct GitHub source, which now returns a 403 Forbidden response because the server either blocks access or has been completely taken offline.

Permanent Solutions

Let's walk through steps to fix this once and for all:

  • Clean up your gem sources
    First, remove the outdated GitHub source (you already did this temporarily, but let's make sure it's gone for good):

    gem sources --remove "http://gems.github.com"
    

    Then, ensure you only have the official, active RubyGems source added:

    gem sources --add "https://rubygems.org/"
    

    Verify your sources list to confirm no old entries remain:

    gem sources -l
    

    You should only see https://rubygems.org/ listed.

  • Install a Bundler version compatible with Ruby 2.5.1
    Ruby 2.5.1 doesn't support the latest Bundler versions (like 3.x). To avoid compatibility issues, install a version that works with your Ruby release:

    # Install a compatible 1.x Bundler version
    gem install bundler -v '~> 1.17'
    # Or, if you prefer 2.x, use a compatible release
    gem install bundler -v '2.0.2'
    

    Both these versions are tested to work smoothly with Ruby 2.5.x.

  • Lock your source configuration permanently
    To prevent this issue from recurring, edit your global gem configuration file (~/.gemrc) to enforce the official source. Add or update the file to contain:

    ---
    sources:
    - https://rubygems.org/
    

    This ensures every gem operation uses the correct, active registry by default.

  • Optional: Use a reliable mirror if you face network issues
    If you're in a region with slow access to the official RubyGems server, you can use a trusted mirror. Just replace the official source with the mirror URL:

    gem sources --remove "https://rubygems.org/"
    gem sources --add "https://gems.ruby-china.com/"
    

    Make sure to only use mirrors from reputable organizations.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 10:51:21