Skip to content

Instantly share code, notes, and snippets.

@scpike
Last active July 6, 2024 14:09
Show Gist options
  • Save scpike/680ceb29a9bdff4eafb123986782c5c1 to your computer and use it in GitHub Desktop.
Save scpike/680ceb29a9bdff4eafb123986782c5c1 to your computer and use it in GitHub Desktop.
Check for silent gem incompatibilities in Rails 7.1
#!/usr/bin/env ruby
# Run like `ruby incompat_71.rb ~/path/to/Gemfile.lock`
# From the team at infield.ai
#
PACKAGES = [['activerecord-import', '1.5.0'],
['anycable-rails', '1.4.1'],
['blazer', '3.0.1'],
['bullet', '7.1.2'],
['data_migrate', '9.2.0'],
['database_cleaner-active_record', '2.1.0'],
['devise', '4.9.3'],
['formtastic', '5.0.0'],
['grape', '2.0.0'],
['has_scope', '0.8.2'],
['honeybadger', '5.1.0'],
['lockbox', '1.3.1'],
['paper_trail', '15.1.0'],
['public_activity', '3.0.0'],
['ransack', '4.1.0'],
['responders', '3.1.1'],
['rollbar', '3.4.1'],
['rspec-rails', '6.1.0'],
['rubocop-rails', '2.22.2'],
['shoulda-matchers', '6.0.0'],
['sidekiq', '7.1.5'],
['simple_form', '5.3.0'],
['slim', '5.2.0'],
['web-console', '4.2.1']].map { |(name, ver)| [name, Gem::Version.new(ver)] }.to_h
require 'bundler'
Bundler::LockfileParser.new(ARGF.read).specs.each do |spec|
name = spec.name
next unless required_version = PACKAGES[name]
if required_version > spec.version
puts "#{name}: Using #{spec.version}. Upgrade to #{required_version}"
end
end
@djfpaagman
Copy link

If you use Action Cable: make sure to also upgrade Redis to >= 4.

This is run time dependency, which got bumped here: rails/rails@7559957

I missed the exceptions in my logs, as pages will just load, and didn't notice the action cable connection was not working.

@scpike
Copy link
Author

scpike commented Jul 5, 2024

@djfpaagman thanks! We've actually made this into a real project at https://github.com/infieldai/gemcompat/blob/main/data/rails/7_1.yaml. I think in order to handle this case we'd need to be able to model the [action cable <-> redis] requirement. If I just add it to our DB for rails then there will be false positives for people not using action cable.

@djfpaagman
Copy link

Yeah that's a bit of bummer with these run time dependencies.

I realized that the redis cache store also requires 4+:
https://github.com/rails/rails/blob/0d30e84878223df68efda3b0e1741611d9682a45/activesupport/lib/active_support/cache/redis_cache_store.rb#L4

So maybe it is safe to say if you use redis to have at least version 4? I don't think it's a breaking change from 3.x and has been released in 2017: https://redis.io/blog/redis-4-0-0-released/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment