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] `undefined method 'version' for nil:NilClass` when running `bundle_report compatibility` #77

Closed tiagocasanovapt closed 1 year ago

tiagocasanovapt commented 1 year ago

Expected Behavior

When running bundle exec bundle_report compatibility --rails-version=5.0.0, I should've received a report of incompatible gems

Actual Behavior

Got an error with the following trace:

Traceback (most recent call last):
    5: from /Users/casanova/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/next_rails-1.2.1/exe/bundle_report:59:in `block in <top (required)>'
    4: from /Users/casanova/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/next_rails-1.2.1/lib/next_rails/bundle_report.rb:16:in `compatibility'
    3: from /Users/casanova/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/next_rails-1.2.1/lib/next_rails/bundle_report.rb:16:in `group_by'
    2: from /Users/casanova/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/next_rails-1.2.1/lib/next_rails/bundle_report.rb:16:in `each'
    1: from /Users/casanova/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/next_rails-1.2.1/lib/next_rails/bundle_report.rb:16:in `block in compatibility'
/Users/casanova/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/next_rails-1.2.1/lib/next_rails/gem_info.rb:82:in `state': undefined method `version' for nil:NilClass (NoMethodError)

To Reproduce

Using private gems from a client, so I can't share the full code to replicate. Used the previous command and identified the failing gem, which contained this gemspec:

$:.push File.expand_path("../lib", __FILE__)
require "gem-name/client/version"

Gem::Specification.new do |s|
  s.name          = 'gem-name'
  s.version       = Gem::Name::VERSION
  s.platform      = Gem::Platform::RUBY
  s.authors       = ['Author Name']
  s.email         = ['author.name@gmail.com']
  s.homepage      = 'http://github.com/Client/gem-name/'
  s.summary       = 'Client extensions to the gem.'
  s.description   = 'Client extensions to the gem. Including our own custom class.'
  s.files         = `git ls-files`.split("\n") - ["gem-name.gemspec"]
  s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
  s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
  s.require_paths = ['lib']
  s.rdoc_options  = ['--charset=UTF-8']
  s.add_runtime_dependency     'money',                 '~> 3.7'
  s.add_runtime_dependency     'rails'
  s.add_development_dependency 'rake'
  s.add_development_dependency 'minitest'
  s.add_development_dependency 'mocha'
  s.add_development_dependency 'sqlite3'
  s.add_development_dependency 'webmock'
  s.add_development_dependency 'vcr'
  s.add_development_dependency 'simplecov'
  s.add_development_dependency 'appraisal'
end

Additional Information

Please contact me if you need further information or to test out a fix locally through a call.

I will abide by the code of conduct

rishijain commented 1 year ago

hey @tiagocasanovapt , what version of next_rails are you using? We have seen this issue but got fixed in v1.2.1. Here is the changelog entry that have the update for v1.2.1 https://github.com/fastruby/next_rails/blob/main/CHANGELOG.md#v121--2022-09-26-commits

tiagocasanovapt commented 1 year ago

It was 1.2.0, new version seems to be working as expected ✅ thanks @rishijain! 👍

sean-dickinson commented 1 year ago

Hm, I'm seeing this same issue on version 1.2.1 of next_rails.

/usr/local/bundle/gems/next_rails-1.2.1/lib/next_rails/gem_info.rb:82:instate': undefined method version' for nil:NilClass (NoMethodError)

I think I see the issue, would you be open to a PR?

etagwerker commented 1 year ago

@sean-dickinson Weird, yes, we are open to a PR. 👍