Skip to content

Order ext/configure-ext.mk after prepare-gems#4

Open
st0012 wants to merge 2 commits into
masterfrom
claude/investigate-docs-build-lnnIc
Open

Order ext/configure-ext.mk after prepare-gems#4
st0012 wants to merge 2 commits into
masterfrom
claude/investigate-docs-build-lnnIc

Conversation

@st0012
Copy link
Copy Markdown
Owner

@st0012 st0012 commented May 14, 2026

Why

After b5e6e0a (Use rbs-integrated RDoc), the daily docs.yml workflow fails on a clean tree. tool/rdoc-srcdir does require 'rdoc/rdoc', RubyGems tries to activate rdoc-7.2.0's new add_dependency 'rbs', '>= 4.0.0', and aborts:

Ignoring rbs-4.0.2 because its extensions are not built. Try: gem pristine rbs --version 4.0.2
...
Could not find 'rbs' (>= 4.0.0) among 84 total gem(s) (Gem::MissingSpecError)
./tool/rdoc-srcdir:4:in 'Kernel#require': cannot load such file -- rdoc/rdoc (LoadError)
make: *** [uncommon.mk:634: html] Error 1

Root cause

ext/configure-ext.mk is regenerated from template/configure-ext.mk.tmpl, which enumerates bundled-gem extensions with

Dir.glob(".bundle/gems/**/extconf.rb", base: srcdir)

Its existing prerequisites — $(PREP) all-incs $(MKFILES) $(RBCONFIG) $(LIBRUBY) template/configure-ext.mk.tmpl update-default-gemspecs — don't include anything that ensures .bundle/gems/ is populated. On a clean tree, file timestamps in a failing make html show:

10:23:22  ext/configure-ext.mk          ← glob runs here, sees nothing
10:23:23  exts.mk                       ← derived; no bundled-gem rules
10:23:32  .bundle/gems/rbs-4.0.2        ← extracted only after both mk files exist

So exts.mk lacks the per-bundled-gem extension build rules, rbs's extconf.rb is never invoked, no .bundle/extensions/.../rbs-4.0.2/gem.build_complete marker is written, and RubyGems then refuses to activate the spec. This was previously latent — nothing in the docs path required a C-extension bundled gem to be activatable until the rdoc bump introduced the runtime dep on rbs.

I verified the diagnosis directly: with no source changes, rm -rf .bundle && make prepare-gems && make html succeeds. Same command without the manual prepare-gems step fails.

How

Add prepare-gems as a prerequisite of ext/configure-ext.mk so the template glob sees the bundled gems. Gated with $(HAVE_BASERUBY:yes=…) — the same pattern prepare-gems itself uses for its subtargets — so the no-baseruby path is preserved.

 ext/configure-ext.mk: $(PREP) all-incs $(MKFILES) $(RBCONFIG) $(LIBRUBY) \
-		$(srcdir)/template/configure-ext.mk.tmpl update-default-gemspecs
+		$(srcdir)/template/configure-ext.mk.tmpl update-default-gemspecs \
+		$(HAVE_BASERUBY:yes=prepare-gems)

Once the ordering is correct, the existing ext/extmk.rb machinery handles the rest: each bundled gem's generated Makefile has all: install and install: gemspec, which both builds the extension (touching gem.build_complete) and copies .bundled.<gem>.gemspec into .bundle/specifications/. RubyGems then finds the spec, sees the build marker, and activates rbs normally.

Follow-ups (not in this PR)

The C-extension special-case in tool/lib/bundled_gem.rb:77-85 — routing those gemspecs into .bundle/gems/<gem>/ and writing a parallel .bundled.<gem>.gemspec — is the structural reason ext/extmk.rb needs that gemspec-copy rule and tool/outdate-bundled-gems.rb needs the second existence check. With the ordering fixed it all works, but consolidating bundled-gem specs into .bundle/specifications/ directly would let three pieces of duplicated machinery be deleted. Worth a separate PR.

https://claude.ai/code/session_01YRoRyZPew2LtN6u6BX8bzx


Generated by Claude Code

@st0012
Copy link
Copy Markdown
Owner Author

st0012 commented May 14, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1662ca071d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread common.mk Outdated
st0012 pushed a commit that referenced this pull request May 14, 2026
Per @chatgpt-codex-connector review on #4: making ext/configure-ext.mk
unconditionally depend on prepare-gems meant plain \`make\`/\`main\`
builds would chain into update-gems, which fetches bundled-gem
archives over the network. That breaks offline builds on a fresh
checkout and mutates the source tree in a way unrelated to the
requested target.

Move the dep to defs/gmake.mk under a MAKECMDGOALS filter for the
docs targets (rdoc, rdoc:%, html, html-server, rdoc-coverage), which
are the only ones whose recipes need bundled-gem extensions
activatable. Plain \`make\` no longer pulls the prepare-gems chain.

Verified:
- \`make -n html\` shows "Extracting bundle gem ..." lines
- \`make -n\` (plain) shows no extraction or download
- \`rm -rf .bundle && make html\` still completes (13895 items)

https://claude.ai/code/session_01YRoRyZPew2LtN6u6BX8bzx
@st0012
Copy link
Copy Markdown
Owner Author

st0012 commented May 14, 2026

@codex review I feel that the current implementation is workarounds spread across different places for different issues. Can you find a more elegant solution.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce85b0359b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread defs/gmake.mk Outdated
Comment on lines +366 to +367
ifneq ($(filter rdoc rdoc\:% html html-server rdoc-coverage,$(MAKECMDGOALS)),)
ext/configure-ext.mk: $(HAVE_BASERUBY:yes=prepare-gems)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match the rdoc: query goal in the guard

When invoking the existing query target as make 'rdoc:Integer#+', MAKECMDGOALS contains rdoc:Integer#+, but this $(filter rdoc\:% ...) entry does not match it in GNU make because : is not special in filter patterns and the backslash is treated literally. As a result the new prepare-gems prerequisite is skipped for the very rdoc:% goal listed here, so a clean tree can still generate ext/configure-ext.mk before bundled gems are extracted and hit the same rdoc/rbs activation failure.

Useful? React with 👍 / 👎.

After b5e6e0a (Use rbs-integrated RDoc), tool/rdoc-srcdir does
require 'rdoc/rdoc' which activates rdoc-7.2.0 and its new
add_dependency 'rbs', '>= 4.0.0'. RubyGems then needs rbs's gemspec
in .bundle/specifications/ and its C extension built. ext/extmk.rb
already handles both via each per-gem Makefile (all -> install ->
gemspec copies .bundled.rbs-*.gemspec into specifications/, and the
TARGET_SO recipe writes gem.build_complete) -- but only if
ext/configure-ext.mk has seen .bundle/gems/ populated when its
template's Dir.glob(".bundle/gems/**/extconf.rb") runs.

On a clean tree, ext/configure-ext.mk regenerates before
prepare-gems extracts anything, so its template glob finds nothing,
exts.mk lacks rules for bundled-gem extensions, the rbs C extension
never compiles, and RubyGems aborts with "Ignoring rbs-4.0.2 because
its extensions are not built."

Add prepare-gems as a prereq of ext/configure-ext.mk, scoped via
MAKECMDGOALS to docs goals only (rdoc, rdoc:%, html, html-server,
rdoc-coverage, undocumented). Plain `make` is untouched, so an
offline-fresh-checkout build doesn't reach prepare-gems -> update-gems.

Also fix tool/update-deps: with the new dep, `make -p all` now
includes rules from inside .bundle/gems/<gem>/ext/<ext>/, where make
prints relative targets like `bigdecimal.o:` whose curdir is under
.bundle/. The existing filter checked the raw target string, missing
these; move the check onto `dir + target` so the full path is what's
inspected. Bundled gems own their depend files, so skipping them here
matches the intent of the original filter.

https://claude.ai/code/session_01YRoRyZPew2LtN6u6BX8bzx
@st0012 st0012 force-pushed the claude/investigate-docs-build-lnnIc branch from ce85b03 to 5affd5f Compare May 14, 2026 13:54
@st0012 st0012 marked this pull request as ready for review May 14, 2026 13:55
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5affd5fab8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread defs/gmake.mk Outdated
# prepare-gems may not have run yet, so make the dep explicit for the
# docs goals. Other targets are left alone so a plain `make` doesn't
# reach for prepare-gems -> update-gems (network).
ifneq ($(filter rdoc rdoc:% html html-server rdoc-coverage undocumented,$(MAKECMDGOALS)),)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include aggregate documentation goals in the guard

When documentation is requested through aggregate targets such as make docs or make install with INSTALLDOC=all, MAKECMDGOALS contains only docs/install, even though common.mk routes those targets to $(DOCTARGETS)/rdoc and srcs-doc. Because this guard stays false in that scenario, a parallel clean-tree docs install can still let main generate ext/configure-ext.mk before srcs-doc runs prepare-gems, leaving the rbs extension out of exts.mk and preserving the activation failure this change is meant to fix.

Useful? React with 👍 / 👎.

Per @chatgpt-codex-connector review on #4: docs is also reached via
\`make docs\` (which routes to srcs-doc + \$(DOCTARGETS)) and via
\`make install INSTALLDOC=all\` (do-install-all has docs in its prereqs).
In those cases MAKECMDGOALS only contains \`docs\` or \`install\`/
\`install-all\`/\`reinstall\`, so the previous filter stayed false and
the ordering between prepare-gems and ext/configure-ext.mk regen was
not enforced -- a clean-tree parallel docs install could still race.

Add \`docs install install-all install-doc install-html install-rdoc
reinstall\` to the filter. For \`make install INSTALLDOC=nodoc\`,
prepare-gems was already pulled in transitively via pre-install-gem,
so this only adds an ordering constraint, not a new fetch.

Verified with \`make -n\` on a clean tree: plain \`make\` does not
extract gems; \`make docs\`, \`make install\`, and \`make html\` do.

https://claude.ai/code/session_01YRoRyZPew2LtN6u6BX8bzx
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9aad8a06bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread defs/gmake.mk
# docs goals. Other targets are left alone so a plain `make` doesn't
# reach for prepare-gems -> update-gems (network).
ifneq ($(filter rdoc rdoc:% html html-server rdoc-coverage undocumented docs install install-all install-doc install-html install-rdoc reinstall,$(MAKECMDGOALS)),)
ext/configure-ext.mk: $(HAVE_BASERUBY:yes=prepare-gems)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Run prepare-gems when RDOC_DEPENDS is empty

When the docs workflow invokes make XRUBY=ruby RDOC_DEPENDS= RBCONFIG=update-rbconfig ... rdoc-coverage/html (checked in .github/workflows/check_misc.yml), the html and rdoc-coverage targets no longer depend on main/srcs-doc, so ext/configure-ext.mk is not requested at all. Adding prepare-gems only as a prerequisite of ext/configure-ext.mk therefore never runs in that CI path, leaving a clean tree able to load rdoc/rdoc before the bundled rbs gem is extracted and built—the failure this change is meant to fix still occurs for the documented workflow.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants