fastruby / next_rails

A toolkit to upgrade your next Rails application
https://www.fastruby.io/blog/upgrade-rails/dual-boot/dual-boot-with-rails-6-0-beta.html?utm_source=github&utm_medium=description&utm_campaign=github&utm_term=next-rails
MIT License
466 stars 28 forks source link

[BUG] bundle_report outdated is raising an exception #72

Closed obromios closed 1 year ago

obromios commented 1 year ago

Version, Branch, or Commit:

What branch/commit/version of "next_rails" you are using? version 1.2.0

Expected behavior: When I run bundle_report outdated I expected to see a list of outdated gems.

Actual behavior:

With version v1.2.0 if I run bundle_report outdated

I see the following exception

  3: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/exe/bundle_report:57:in `block in <top (required)>'
  2: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/bundle_report.rb:100:in `outdated'
  1: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/bundle_report.rb:100:in `reject'
/Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/gem_info.rb:72:in `up_to_date?': undefined local variable or method `latest_version' for #<NextRails::GemInfo:0x00007fecaa2b1990> (NameError)

However if I revert to v1.0.4 then bundle_report outdated does provide a list of outdated gems.

As well in v1.2.0 if I run bundle_report compatability it gives the following exception

from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/exe/bundle_report:59:in `block in <top (required)>'
  4: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/bundle_report.rb:16:in `compatibility'
  3: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/bundle_report.rb:16:in `group_by'
  2: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/bundle_report.rb:16:in `each'
  1: from /Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/bundle_report.rb:16:in `block in compatibility'
/Users/myname/.rvm/gems/ruby-2.7.6/gems/next_rails-1.2.0/lib/next_rails/gem_info.rb:82:in `state': undefined method `version' for nil:NilClass (NoMethodError)

I worked out this is because I was not providing the --rails-version option but in v1.0.4, bundle_report compatability does list the incompatibilities for upgrading to version 5 of rails. Which is not particularly helpful, but nicer than generating an exception. Perhaps a new feature would be to give an error message if someone forgets to add the --rails-version option along the lines of

warning - need to specify the rails version with the --rails-version option.

Steps to reproduce:

How do I achieve this behavior? Install next_rails gem in Gemfile and bundle install, then

  1. bundle_report outdated
  2. bundle_report compatability Context and environment:

Provide any relevant information about your setup (Customize the list accordingly based on what info is relevant to this project)

  1. Version of the software the issue is being opened for.
  2. Operating System: MacOS
  3. Operating System version 12.5.1
  4. Ruby version: 2.7.6

I will abide by the code of conduct

rishijain commented 1 year ago

hey @obromios , the bug is fixed in v1.2.1 version of the gem. Kindly use that for the fix. Thank you for reporting it. I am closing this issue for now.