Fetching sass-embedded 1.100.0 (x86_64-linux-gnu) froze

The build got stuck on this package today. Does anyone have any good workarounds? Using a mirror source didn’t help either.


Fetching gem metadata from https://mirrors.tuna.tsinghua.edu.cn/rubygems/.
Fetching bundler 4.0.11
Installing bundler 4.0.11
Fetching gem metadata from https://rubygems.org/........


Fetching rotp 6.3.0
Fetching rubyzip 3.3.1
Fetching sanitize 7.0.1
Fetching sass-embedded 1.100.0 (x86_64-linux-gnu)

Fixing discourse_docker Build: Frozen Even with Mirror Configured Due to rubygems.org

Context (Root Cause)

Key sequence in the build log:

Fetching gem metadata from https://mirrors.tuna.tsinghua.edu.cn/rubygems/.   ← First run (base image's Bundler 4.1.x), mirror effective
Fetching bundler 4.0.11 / Installing bundler 4.0.11                          ← Gemfile.lock's BUNDLED WITH=4.0.11 triggers auto-install and re-exec
Fetching gem metadata from https://rubygems.org/........                     ← Second run (Bundler 4.0.11), mirror silently ignored
Fetching rotp / rubyzip / sanitize / sass-embedded ...                       ← Downloading from rubygems.org → stalls on domestic network

Verified facts:

  1. Gemfile.lock has BUNDLED WITH = 4.0.11 (confirmed on local release/2026.7 branch, Gemfile.lock:1339); discourse_docker’s base image includes a newer Bundler (4.1.x), so the build automatically installs 4.0.11 and re-execs.
  2. Bundler 4.0.11’s mirror matching code is identical to 2.x (key regex \Amirror\.(all|.+?)(\.fallback_timeout)?\/?\z, matching by normalized URI first, then host) — the mirror mechanism itself was not removed.
  3. The actual root cause is ruby/rubygems#10073 / #10075 (reported 2026-11-16, this week):
    • Bundler 4.1 uses full Gem::YAMLSerializer to write .bundle/config, quoting all keys containing : → writes "mirror.https://rubygems.org/": "https://..."
    • Bundler 4.0 uses RubyGems 3.5–4.0’s simplified reader, treating quotes as part of the key → mirror config is silently ignored, falling back to original source rubygems.org
  4. Thus: Config written by 4.1 is readable by itself (first run uses tuna), but unreadable by 4.0.11 after re-exec (second run uses rubygems.org). Upstream fix for the writer side is in Bundler 4.1.1, but Discourse locks BUNDLED WITH to 4.0.11, so builds always fall back to 4.0.11 — we must work around it in the config.

Recommended Fix: Switch to mirror.all

The key mirror.all contains no colon, so Bundler 4.1’s writer won’t quote it, and 4.0.11’s reader can recognize it properly; the reader regex in versions 2.7 through 4.x supports all. For a Discourse project with a single rubygems source, this is equivalent to mirror.https://rubygems.org/.

Action: Find the existing bundle config mirror... command on the server (in containers/app.yml hooks, custom template, or modified templates/web.template.yml), change the mirror key to mirror.all, keeping the rest as is (especially maintain the same user context for bundle install, e.g., su discourse -c):

- exec:
    cmd:
      - su discourse -c 'bundle config set --global mirror.all https://mirrors.tuna.tsinghua.edu.cn/rubygems/'

If you can’t find the original location, add a hook directly in containers/<app>.yml (the bundle install exec in web.template.yml has hook: bundle_exec, and pups supports before_/after_ prefix injection):

hooks:
  before_bundle_exec:
    - exec:
        cmd:
          - su discourse -c 'bundle config set --global mirror.all https://mirrors.tuna.tsinghua.edu.cn/rubygems/'

Note: Replace the old mirror.https://rubygems.org/... command, don’t keep both; don’t configure mirror.*.fallback_timeout (if the mirror is slow, it falls back to rubygems.org, reproducing the stall).

Alternative Fix (If mirror.all is Still Bypassed): Rewrite Gemfile and Lock Remote Directly

Completely bypass bundler config mechanism, replacing the source with the mirror directly (after_code hook executes after git checkout, before bundle):

hooks:
  after_code:
    - exec:
        cd: $home
        cmd:
          - sed -i 's|https://rubygems.org|https://mirrors.tuna.tsinghua.edu.cn/rubygems/|g' Gemfile
          - sed -i 's|remote: https://rubygems.org/|remote: https://mirrors.tuna.tsinghua.edu.cn/rubygems/|g' Gemfile.lock

Verification

  1. (Optional, 30-second root cause check) Check if existing config was written by 4.1 with quoted keys on the server:
    cd /var/discourse && ./launcher enter app   # Or any method to enter the container
    grep -rn mirror /home/discourse/.bundle/config /var/www/discourse/.bundle/config /root/.bundle/config 2>/dev/null
    # If you see "mirror.https://rubygems.org/": (key with quotes) → root cause confirmed
    
  2. ./launcher rebuild app, observe bundle step logs:
    • Should only see Fetching gem metadata from https://mirrors.tuna.tsinghua.edu.cn/rubygems/
    • Should not see Fetching gem metadata from https://rubygems.org/
    • rotp / rubyzip / sanitize / sass-embedded download successfully
  3. Image build succeeds, container starts, site is accessible.

Follow-up

  • Upstream ruby/rubygems#10075 writer fix released with Bundler 4.1.1; once discourse/base image includes ≥4.1.1, the old mirror.https://rubygems.org/ style will work again. mirror.all is safe on both old and new versions, so it can be kept permanently.
  • Background references: Bundler 4 Upgrade Notes, long-standing issue of bundler self-install using rubygems.org #5498 / #8999 (in this case, the 4.0.11 self-install step succeeded and was not the bottleneck).