Skip to content

build: toys spec fails with GemNotFound for local gem #573

@quartzmo

Description

@quartzmo

Description

When running toys spec or toys integration in a clean CI environment (like GitHub Actions), the task fails with a Bundler::GemNotFound error for the local gem being developed.

Error Log

Could not find gem 'googleauth (= 1.16.2)' in locally installed gems (Bundler::GemNotFound)

Or:

Could not find gem 'googleauth' in locally installed gems (Bundler::GemNotFound)

This occurs while attempting to install or update a temporary Gemfile created by Toys: /.toys-tmp-gemfile-....

Root Cause

We investigated the source code of the toys gem and found that:

  1. In toys-core/lib/toys/utils/gems.rb, the method create_modified_gemfile creates a temporary Gemfile.
  2. It iterates over all already loaded gems in the current Ruby process and forces them to be resolved at their exact loaded version in the temporary Gemfile.
  3. Since googleauth is loaded by Toys to parse tasks, it is included in loaded_gems.
  4. However, it does not add path: '.' for the local gem, so the temporary Gemfile ends up with gem 'googleauth', '= 1.16.2' (or similar) without a path source.
  5. Bundler therefore fails to find it in remote gems.

Workaround

Use bundle exec rspec or bundle exec ruby directly in CI or create a custom task that doesn't use the toys RSpec/Minitest templates with t.use_bundler.

Metadata

Metadata

Assignees

Labels

type: processA process-related concern. May include testing, release, or the like.

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