Skip to content

Quote the test loader path in Rake::TestTask - #780

Open
wtn wants to merge 1 commit into
ruby:masterfrom
wtn:space
Open

wtn wants to merge 1 commit into
ruby:masterfrom
wtn:space

Conversation

@wtn

@wtn wtn commented Nov 15, 2026 •

Copy link
Copy Markdown

Rake::TestTask runs the tests through a single shell string. The test files and the -I load path are wrapped in double quotes, but with the default :rake loader the path to rake_test_loader.rb is interpolated bare. When rake is installed under a directory whose name contains a space (a home directory with a space, or a project such as ~/My Projects/app using bundle config path vendor/bundle), the shell splits the loader path and rake test fails:

ruby: No such file or directory -- /path/to/My (LoadError)
rake aborted!
Command failed with status (1)

This is a regression. The loader path was quoted from 87e39db (2009) until 063950d (#357, "Simplify default rake test loader") replaced "\"#{rake_loader}\"" with an unquoted -r argument, and 37635e6 later changed that argument to the current form without adding quotes.

Fix

This change wraps the loader path in double quotes in TestTask#run_code, restoring the quoting that 063950d removed and matching how file_list_string and ruby_opts_string quote their paths.

A functional test runs a test task from a copy of lib under a temporary directory named rake with space.

The path to rake_test_loader.rb was interpolated into the shell command
unquoted, so the test task failed when rake was installed under a
directory with a space in its name.

Co-authored-by: Claude Mythos 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant