rails: Valid rake command line arguments reported as invalid on running 'test' task

Steps to reproduce

rbenv shell 2.3.0
gem install rails -v '5.0.0.beta3'
rails new test-a
cd test-a
echo "gem 'therubyracer', platforms: :ruby" >> Gemfile
bundle install && bundle update
which rake
bundle exec which rake
#Next two lines works fine
rake --rakefile "`pwd`/Rakefile" about
rake --rakefile "`pwd`/Rakefile" --tasks
# Next two lines would fail with output: "invalid option: --rakefile"
rake --rakefile "`pwd`/Rakefile" test
bundle exec rake --rakefile "`pwd`/Rakefile" test

Expected behavior

It should work šŸ˜‰ Rake arguments should be passed to rake.

Actual behavior

Got exit code 1 and ā€œinvalid option: --rakefileā€ output

After some ā€˜debugging’ I’ve next stacktrace:

invalid option: --rakefile
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.0.beta3/lib/rails/test_unit/minitest_plugin.rb:57:in `plugin_rails_options'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:190:in `block (2 levels) in process_args'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:188:in `each'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:188:in `block in process_args'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:162:in `new'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:162:in `process_args'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:116:in `run'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.0.beta3/lib/rails/test_unit/minitest_plugin.rb:64:in `rake_run'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/railties-5.0.0.beta3/lib/rails/test_unit/testing.rake:15:in `block in <top (required)>'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:248:in `block in execute'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `each'
/home/vlad/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-11.1.2/lib/rake/task.rb:243:in `execute'

It seems test framework tries to parse all rake cli arguments

System configuration

Rails version: 5.0.0.beta3

Ruby version: 2.3.0 by rbenv

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 26 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@VladRassokhin yep, I see it now. Got led astray by other comments and didn’t check the test command. Doing so, I can reproduce this.

Thanks for your patience! ā¤ļø

@VladRassokhin both --trace and --rakefile seem to work on master for me. Can you update and verify with your app?

@mchristen are you sure -t is a supported Rake option? Doesn’t it confuse with -T (list all tasks)?

Problem is still there:

vlad@unit-421 /tmp/tmp.e4OzBfz5Uv/test-x $ bundle exec rake --rakefile Rakefile --trace test
** Invoke test (first_time)
** Execute test
invalid option: --rakefile

Gemfile.lock and bundle install output.

My app is just simple rails new test-x and there nothing special in it. It seems there’s something else here since it work for someone and works not for another. Maybe there’s some difference in our RUBYLIB paths or other hidden parameters? Will try a bit later - on vacation now.