Ruby "rspec --bisect" Fails or Stalls in CI
rspec --bisect tries to minimize the set of examples that reproduce an order-dependent failure, but it only works when the failure is deterministic for a given order. Flaky, parallel, or externally-stateful tests make bisect fail or loop.
What this error means
rspec --bisect cannot narrow the failure - it reports it could not reproduce, runs indefinitely, or yields an unhelpful minimal set. The underlying test passes and fails inconsistently for the same order.
Bisect started using options: "--seed 12345"
Running suite to find failures... 1 failure found
Starting bisect with 1 failing example and 240 non-failing examples.
Bisect aborted! The bisect process failed to reproduce the failure.Common causes
Failure is not deterministic for an order
Bisect assumes a given example order reproduces the failure every time. If the failure depends on wall-clock time, randomness, or external state, it does not reproduce reliably and bisect aborts.
Parallelism or shared state interferes
Running bisect against a suite that uses parallel workers or shared global state breaks the one-order-one-result assumption bisect relies on.
How to fix it
Make the failure reproducible first
Pin the seed and run serially so the order-dependent failure is deterministic before bisecting.
bundle exec rspec --seed 12345 --order defined # confirm it fails
bundle exec rspec --bisect --seed 12345Remove non-determinism, then bisect
- Run bisect serially (not under parallel_tests).
- Eliminate reliance on real time/randomness in the suspect specs (freeze time, seed RNG).
- Ensure global state is reset between examples so order is the only variable.
How to prevent it
- Keep tests independent and free of shared global state.
- Run --bisect serially with a fixed seed.
- Stub time/randomness so order is the only source of failure.