ViewComponent/view_component · error
WARNING: Template format for #{path} is missing, defaulting
Error message
WARNING: Template format for #{path} is missing, defaulting to :html. What it means
Error "WARNING: Template format for #{path} is missing, defaulting to :html." thrown in ViewComponent/view_component.
Source
Thrown at lib/view_component/template.rb:27
attr_reader :details, :path
delegate :virtual_path, to: :@component
delegate :format, :variant, to: :@details
def initialize(component:, details:, lineno: nil, path: nil)
@component = component
@details = details
@lineno = lineno
@path = path
end
class File < Template
def initialize(component:, details:, path:)
# If the template file has no format (e.g. .erb instead of .html.erb),
# assume the default format (html).
if details.format.nil?
Kernel.warn("WARNING: Template format for #{path} is missing, defaulting to :html.")
details = ActionView::TemplateDetails.new(details.locale, details.handler, DEFAULT_FORMAT, details.variant)
end
super
end
def type
:file
end
# Load file each time we look up #source in case the file has been modified
def source
::File.read(@path)
end
private
# Rails 8.1 added a newline to compiled ERB output (rails/rails#53731).View on GitHub (pinned to 9f22c36fa7)
Solutions
- Add an explicit format to the template file name, e.g. rename my_component.erb to my_component.html.erb.
- If another format is intended, name the template accordingly, e.g. my_component.json.jbuilder.
When it happens
Trigger: Thrown at lib/view_component/template.rb:27 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ViewComponent/view_component@9f22c36fa7 (2026-08-23).
Data as JSON: /api/errors/0ac16280405f27e2.
Report an issue: GitHub.