Skip to content

index_workspace fails with FileError on the rails meta-gem #803

@andrewmcodes

Description

@andrewmcodes

Summary

Following the basic usage example in the README, Rubydex::Graph#index_workspace returns a FileError for the rails gem because the gem is a meta-gem and ships without a lib/ directory. RubyGems still resolves a default require path of lib for it, and Rubydex treats the missing directory as a hard error.

Reproduction

In a Rails 8 application's console:

graph = Rubydex::Graph.new
# => #<Rubydex::Graph:0x000000013fcad8f8 @workspace_path="/path/to/app">

graph.encoding = "utf16"
# => "utf16"

graph.index_workspace
# => ["FileError: Path `/path/to/app/.bundle/ruby/4.0.0/gems/rails-8.0.2.1/lib` does not exist"]

Expected behavior

index_workspace should successfully index the workspace and its dependencies. The rails meta-gem should be tolerated (skipped, or its missing lib/ ignored) rather than producing a FileError.

Root cause

The rails-8.0.2.1 gem installs only:

.../gems/rails-8.0.2.1/
├── MIT-LICENSE
└── README.md

The source rails.gemspec does not explicitly set require_paths. RubyGems falls back to its built-in default of ["lib"], defined in Gem::Specification's default-value table:

# rubygems/specification.rb
require_paths: ["lib"],

The setter's RDoc states the same:

The default value is "lib".

You can confirm this with no network access:

$ ruby -e 'require "rubygems"; p Gem::Specification.default_value(:require_paths)'
# => ["lib"]

$ ruby -e 'require "rubygems"; p Gem::Specification.new.require_paths'
# => ["lib"]

As a result, the RubyGems-generated stub spec at specifications/rails-8.0.2.1.gemspec writes the default back out:

s.require_paths = ["lib".freeze]

…even though no lib/ directory exists in the gem. Rubydex appears to iterate over each dependency's resolved require_paths and raise FileError when the directory is missing. Any meta-gem in this shape will hit this, and rails itself is almost always a direct dependency of Rails apps, so this is broadly reproducible.

Environment

  • Rubydex: 0.2.3 (arm64-darwin)
  • Ruby: 4.0.3
  • Bundler: 4.x (custom BUNDLE_PATH pointing at a project-local .bundle/)
  • Rails: 8.0.2.1
  • OS: macOS (Darwin 25.5.0, Apple Silicon)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions