How to solve error cannot load such file -- stripe_mock (LoadError) when running tests with Cucumber?
When you use knapsack_pro
for Cucumber in Knapsack Pro Regular Mode (bundle exec rake knapsack_pro:cucumber
) you may have a problem with loading your project code because Knapsack Pro uses Cucumber::Rake::Task
. To solve issue like:
cannot load such file -- stripe_mock (LoadError)
You can set environment variable:
export BUNDLE_DISABLE_EXEC_LOAD=true
What is BUNDLE_DISABLE_EXEC_LOAD
?
disable_exec_load
(BUNDLE_DISABLE_EXEC_LOAD
): Stop Bundler from using load to launch an executable in-process in bundle exec
.
Source: https://bundler.io/man/bundle-config.1.html
How does loading work in bundler?
By default, when attempting to bundle exec
to a file with a ruby shebang, Bundler will Kernel.load
that file instead of using Kernel.exec
. For the vast majority of cases, this is a performance improvement. In a rare few cases, this could cause some subtle side-effects (such as dependence on the exact contents of $0
or __FILE__
) and the optimization can be disabled by enabling the disable_exec_load
setting.