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:
- In
toys-core/lib/toys/utils/gems.rb, the method create_modified_gemfile creates a temporary Gemfile.
- 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.
- Since
googleauth is loaded by Toys to parse tasks, it is included in loaded_gems.
- 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.
- 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.
Description
When running
toys specortoys integrationin a clean CI environment (like GitHub Actions), the task fails with aBundler::GemNotFounderror for the local gem being developed.Error Log
Or:
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
toysgem and found that:toys-core/lib/toys/utils/gems.rb, the methodcreate_modified_gemfilecreates a temporary Gemfile.googleauthis loaded by Toys to parse tasks, it is included inloaded_gems.path: '.'for the local gem, so the temporary Gemfile ends up withgem 'googleauth', '= 1.16.2'(or similar) without a path source.Workaround
Use
bundle exec rspecorbundle exec rubydirectly in CI or create a custom task that doesn't use thetoysRSpec/Minitest templates witht.use_bundler.