The process generating environment ( ENV ) is transferred to the sub-shell. Or the cucumber itself, as you use the cucumber (for example, bundle exec cucumber ), your scripts or the code downloaded by the script (for example, the application and, therefore, the bundle), mess with your ENV . Environment variables such as RUBYLIB , GEM_PATH and BUNDLE_GEMFILE can significantly affect the way your sub-Ruby processes can load / run.
Try printing the ENV variable in your script and compare it with what you get when you do this with ruby -rubygems -rpp -e "pp ENV" or just ENV on the command line.
For what it's worth, a possible alternative would be to load and call the rake task directly, for example, Rake::Task['db:schema:load'].invoke , without using a sub-shell. However, it depends on what you are trying to do.
source share