1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix rails new --dev

Follow-up to #38429.

`Rails::Command.invoke` passes arguments through to the appropriate
command class.  However, some command classes were ignoring those
arguments, and instead relying on the contents of ARGV.  In particular,
RakeCommand expected ARGV to contain the arguments necessary to the Rake
task, and no other arguments.  This caused the `webpacker:install` task
to fail when the `--dev` option from `rails new --dev` remained in ARGV.

This commit changes the relevant command classes to not rely on the
previous contents of ARGV.  This commit also adds a missing `require`
for use of `Kernel#silence_warnings`.

Fixes #38459.
This commit is contained in:
Jonathan Hefner 2020-02-14 14:24:09 -06:00
parent 13cc79f996
commit 7e54d3bc21
3 changed files with 4 additions and 3 deletions

View file

@ -21,7 +21,7 @@ module Rails
require_application_and_environment!
load_generators
ARGV.shift
ARGV.replace(args) # set up ARGV for third-party libraries
Rails::Generators.invoke generator, args, behavior: :invoke, destination_root: Rails::Command.root
end

View file

@ -12,10 +12,10 @@ module Rails
formatted_rake_tasks.map(&:first)
end
def perform(task, *)
def perform(task, args, config)
require_rake
ARGV.unshift(task) # Prepend the task, so Rake knows how to run it.
ARGV.replace([task, *args]) # set up ARGV for Rake
Rake.application.standard_exception_handling do
Rake.application.init("rails")

View file

@ -1,6 +1,7 @@
# frozen_string_literal: true
require "shellwords"
require "active_support/core_ext/kernel/reporting"
require "active_support/core_ext/string/strip"
module Rails