Repository navigation
Mark the error pages written by rails new as generated - #8191
Open
irinanazarova wants to merge 3 commits into
Open
irinanazarova wants to merge 3 commits into
irinanazarova wants to merge 3 commits into
Conversation
Rails writes five static error pages into public/ (400, 404,
406-unsupported-browser, 422 and 500). Since Rails 8.0 they total
about 36 KB of HTML, more than the ~24 KB of Ruby in a freshly
generated application, so a new Rails application is reported as an
HTML repository until enough Ruby has been written.
A file is treated as generated when its path is one of the five
public/*.html names and it contains the comment Rails has written into
each page since 3.0, naming that same path:
<!-- This file lives in public/404.html -->
A page rewritten without the comment, or the same content under
another path, is not affected. Fixtures are untouched output of
rails new on Rails 8.1.3.1, plus a hand-written 404.html that must
not match.
Rails has merged the same exclusion for newly generated applications
via .gitattributes (rails/rails#58693); this covers applications
generated with Rails 8.0 and 8.1 before that change, and those created
with --skip-git, which get no .gitattributes.
lildude
requested changes
Nov 26, 2026
| return lines[0].include?("% Generated by roxygen2: do not edit by hand") | ||
| end | ||
|
|
||
| RAILS_ERROR_PAGES = %w[400 404 406-unsupported-browser 422 500] |
Member
There was a problem hiding this comment.
There's no need for a constant as this isn't going to be used anywhere else. Please put this line in the method.
Author
There was a problem hiding this comment.
Thank you for reviewing!! Just moved it into a method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Treat the five error pages that
rails newwrites intopublic/as generated, so that a new Ruby on Rails application is classified as Ruby rather than HTML.Description
Motivation
Every new Rails application since Rails 8.0 is reported as an HTML repository on GitHub. Measured on a uniform sample of 20,000 HTML-primary repositories per year, Rails applications reported as HTML run at about 600 a month in 2025 and about 1,100 a month in 2026. Any statistic derived from GitHub language data, such as new Rails applications or new Ruby developers, undercounts Ruby.
rails newwrites five static error pages (400.html,404.html,406-unsupported-browser.html,422.html,500.html). Since Rails 8.0 they total about 36 KB of HTML, while a freshly generated application contains about 24 KB of Ruby. Linguist picks the primary language by byte count, so the application is HTML until its author has written roughly 13 KB of Ruby.Reproduction
Before: https://github.com/irinanazarova/rails-new is the unmodified output of
rails _8.1.3.1_ new rails-new --skip-bundle. GitHub reports it as HTML (57.9% HTML, 35.5% Ruby).After: https://github.com/irinanazarova/rails-new-amended is the same application with the five files marked
linguist-generatedin.gitattributes. GitHub reports it as Ruby (80%).Detail
Adds
generated_rails_error_page?togenerated.rb. A file qualifies only if its path ispublic/<one of the five names>.htmland it contains the marker comment the Rails generator has written into each page since Rails 3.0, naming that same path (<!-- This file lives in public/404.html -->). A page a developer has rewritten without the marker, or the same content under another path, is not affected. Fixtures are the untouched output ofrails newon Rails 8.1.3.1, plus a hand-writtenpublic/404.htmlasserting no match.Why in Linguist, given the Rails-side fix
Rails has merged the companion change, rails/rails#58693, which adds these five
linguist-generatedentries to the.gitattributesof every newly generated application. That covers applications generated with future Rails releases. It does not reach the applications generated with Rails 8.0 and 8.1 since November 2024, nor applications created with--skip-git, which get no.gitattributes. This heuristic covers those on their next statistics run.Checklist: