Conversation
The purpose of this test is to exercise the happy path of running a job in the context of a full Rails app, including the upcoming Railtie we'll be adding.
| # It is unclear why we need to do this, but otherwise it blows up with: | ||
| # Could not find <the gems below> in any of the sources (Bundler::GemNotFound) | ||
| run_or_raise("gem", "install", "nio4r") | ||
| run_or_raise("gem", "install", "websocket-driver") | ||
| run_or_raise("gem", "install", "date") | ||
| run_or_raise("gem", "install", "racc") | ||
|
|
||
| # It is also unclear why we need to --skip-install, lock, and install, instead of just using `bundle add`, | ||
| # but, again, otherwise it blows up with the same error as above. | ||
| run_or_raise("bundle", "add", "rails", "--version", rails_version.to_s, "--skip-install") | ||
| run_or_raise("bundle", "lock") | ||
| run_or_raise("bundle", "install") |
There was a problem hiding this comment.
There's something really weird going on here. I had to add all of this for it to run locally, but we still run into this error in CI, just for different gems.
I think there's something weird going on, to do with Bundler/Rubygems environment variables or something, and the interaction with running bundler within this app.
There was a problem hiding this comment.
You might want to use Bundler.with_unbundled_env:
https://bundler.io/v4.0/man/bundle-exec.1.html#Shelling-out
Any Ruby code that opens a subshell (like system, backticks, or %x{}) will automatically use the current Bundler environment. If you need to shell out to a Ruby command that is not part of your current bundle, use the with_unbundled_env method with a block. Any subshells created inside the block will be given the environment present before Bundler was activated
I discovered this whilst working on a blackbox testing utility to write specs like the integration spec you're adding here... shameless plug:
https://github.com/odlp/jet_black?tab=readme-ov-file#clean-bundler-environment
The purpose of this test is to exercise the happy path of running a job in the context of a full Rails app, including the upcoming Railtie we'll be adding in #441.