ruby_llm-mcp icon indicating copy to clipboard operation
ruby_llm-mcp copied to clipboard

Add Zeitwerk eager loading check to CI

Open trevorturk opened this issue 1 year ago • 5 comments

Summary

  • Adds Zeitwerk::Loader.eager_load_all validation to the CI test job
  • Runs after Ruby dependencies are installed and before Bun fixtures/specs
  • Rebased onto current patvice/main after ruby_llm-mcp PR #94 was merged

Problem

Without automated Zeitwerk eager loading validation, autoloading issues can slip into production causing crashes. These issues include:

  • Inflector configuration errors
  • Constant definition problems
  • Missing conditional checks for optional dependencies

Solution

Add a simple validation step that runs Zeitwerk::Loader.eager_load_all after dependency installation. This structural validation provides fast feedback before the rest of the test job continues.

Upstream Status

The original blocker in RubyLLM has been fixed on ruby_llm main:

  • ruby_llm#504 merged on May 6, 2026 and fixes the ActiveRecord dependency/eager-loading failure.
  • ruby_llm#505 was closed unmerged on March 1, 2026, so this PR no longer treats it as a blocker.

This PR remains draft until a published ruby_llm gem release includes #504. The current latest RubyGems release is ruby_llm 1.14.1 from April 2, 2026, which still predates the fix.

Testing

Local verification after rebasing still fails with the expected upstream gem issue because Bundler resolves ruby_llm 1.14.1:

uninitialized constant RubyLLM::ActiveRecord::ActsAs::ActiveSupport (NameError)

Command run locally:

RBENV_VERSION=3.4.9 rbenv exec bundle exec ruby -e "require 'ruby_llm/mcp'; Zeitwerk::Loader.eager_load_all"

trevorturk avatar Nov 18 '25 17:11 trevorturk

Hey! Thanks for the PR -- I'm open to this if your downstream changes merged into RubyLLM

Only question is that Zeitwerk::Loader.eager_load_all is going to load all ruby files within a project. Right now it's failing in my CI due to ActiveSupport not be available when loading RubyLLM gem. That is not a hard dependency of RubyLLM or MCP gem, so I am wondering if there is not some work to do to exclude those files or had checks within.

Whatever RubyLLM provides as it solution for this, I'm happy to follow.

patvice avatar Nov 19 '25 16:11 patvice

Looks like I commented to soon and https://github.com/patvice/ruby_llm-mcp/pull/94 provides that solution.

Happy to merge this once RubyLLM does

patvice avatar Nov 19 '25 16:11 patvice

Sounds good, thanks! Also note this is entirely optional and pedantic, so if it's annoying later on of course feel free to remove!

trevorturk avatar Nov 19 '25 16:11 trevorturk

https://github.com/crmne/ruby_llm/pull/504 was merged, so I'll keep an eye out for a RubyLLM release and then mark this ready for review...!

trevorturk avatar May 06 '26 17:05 trevorturk

Ok, we're live: https://github.com/crmne/ruby_llm/releases/tag/1.15.0

trevorturk avatar May 07 '26 01:05 trevorturk