-
Notifications
You must be signed in to change notification settings - Fork 552
Closed
Description
I ran into this while writing a Rails template. Consider this small template:
# insert_into_file_test.rb
insert_into_file "some_file" do
"hello this is content for some_file"
end
Running rails new -m insert_into_file_test.rb test-insert-into-file-test
fails with:
apply /Users/technicalpickles/src/insert_into_file_test.rb
/Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:35:in `merge': no implicit conversion of nil into Hash (TypeError)
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:35:in `initialize'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:27:in `new'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:27:in `insert_into_file'
from /Users/technicalpickles/src/insert_into_file_test.rb:1:in `apply'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions.rb:224:in `instance_eval'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions.rb:224:in `apply'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/generators/app_base.rb:162:in `apply_rails_template'
from (eval):1:in `apply_rails_template'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `block in invoke_all'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `each'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `map'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `invoke_all'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/group.rb:232:in `dispatch'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/commands/application/application_command.rb:24:in `perform'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/command/base.rb:63:in `perform'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/command.rb:44:in `invoke'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/cli.rb:16:in `<top (required)>'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
from /Users/technicalpickles/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/exe/rails:9:in `<top (required)>'
from /Users/technicalpickles/.rbenv/versions/2.4.1/bin/rails:22:in `load'
from /Users/technicalpickles/.rbenv/versions/2.4.1/bin/rails:22:in `<main>'
Clearly a developer error, since most uses of this require the use of :after
to indicate where to insert the content. It looks like :before
or :after
are required, so if there is neither, that should be an error.
Rails is using the most recent thor, 0.19.4, and the same code seems to be in master.
Metadata
Metadata
Assignees
Labels
No labels