amatsuda / traceroute

A Rake task gem that helps you find the unused routes and controller actions for your Rails 3+ app
MIT License
902 stars 38 forks source link

rake task results aren't working as expected in Rails 8.0.0 #49

Open hasehiro25 opened 5 days ago

hasehiro25 commented 5 days ago

Hi It seems like traceroute doesn't work as expected in Rails 8.0.0.

I made a new rails app with scaffold and got the following in Rails 8.0.0.


# Gemfile.lock
traceroute (0.8.1)

# routes.rb
Rails.application.routes.draw do
  resources :users
  ...
end

bin/rails traceroute

exec log ``` ❯ bin/rails -v Rails 8.0.0 ❯ bin/rails traceroute Unused routes (0): Unreachable action methods (26): turbo/native/navigation#refresh turbo/native/navigation#recede turbo/native/navigation#resume active_storage/blobs/proxy#send_stream active_storage/representations/proxy#send_stream rails/conductor/action_mailbox/inbound_emails/sources#create rails/conductor/action_mailbox/inbound_emails/sources#new rails/conductor/action_mailbox/reroutes#create rails/conductor/action_mailbox/incinerates#create rails/conductor/action_mailbox/inbound_emails#new rails/conductor/action_mailbox/inbound_emails#create rails/conductor/action_mailbox/inbound_emails#index rails/conductor/action_mailbox/inbound_emails#show action_mailbox/ingresses/sendgrid/inbound_emails#create action_mailbox/ingresses/relay/inbound_emails#create action_mailbox/ingresses/postmark/inbound_emails#create action_mailbox/ingresses/mandrill/inbound_emails#create action_mailbox/ingresses/mandrill/inbound_emails#health_check action_mailbox/ingresses/mailgun/inbound_emails#create users#destroy users#new users#edit users#update users#create users#index users#show ```

I found it working as expected in Rails 8.0.0.rc2

bin/rails -v
Rails 8.0.0.rc2

❯ bin/rails traceroute
Unused routes (1):
  rails/health#show

Unreachable action methods (2):
  active_storage/blobs/proxy#send_stream
  active_storage/representations/proxy#send_stream

Just a guess, but maybe it is caused due to the change of the routes loading? https://github.com/rails/rails/pull/53522

yenshirak commented 5 days ago

Yes, it's related to that PR. As a workaround you can create a patched rake task:

task patched_traceroute: :environment do
  Rails.application.reload_routes_unless_loaded
  Rake::Task[:traceroute].execute
end

I planned to submit a PR but the test suite seems to be in a bad shape:

hasehiro25 commented 5 days ago

Thank you for the workaround! Helped me out 👍