New and Gone Gems in Rails 7

New Default Gems

importmap-rails
# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails", ">= 0.3.4"

See Importmap-Rails discussion above.

turbo-rails and stimulus-rails
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails", ">= 0.7.11"

# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
gem "stimulus-rails", ">= 0.4.0"
Hello ruby debug

A tool called ruby debug now is the default debugger in Rails. This replaces byebug, which was the default and preferred Ruby debugger for Rails 6 and Ruby 2.

group :development, :test do
  # Start debugger with binding.b [https://github.com/ruby/debug]
  gem "debug", ">= 1.0.0", platforms: %i[ mri mingw x64_mingw ]
end

Here’s the commit that says goodbye to byebug. The explanation is that Byebug is not fully compatible with Zeitwork. Zeitwork is a Ruby framework that makes reloading of code easier and safer in thread-dependent environments.

Can I stil use byebug with Rails 7?

If you aren’t using Zeitwork or don’t have namespaced Ruby files, then yet. The issue with the Zeitwork framework, which is design to reload Ruby files as you change them, is related to namespaced Ruby that doesn’t reload properly. If you run into these issues, it’s better to switch to pry or ruby debug.

Can I still use pry debugger with Rails 7?

Sure. One of the features some Rubyists like pry over the other choices is the navigate around feature (cd), which lets you move around your code while inside of the debugger.

Gone Default Gems

Of course, you can always add these back. These gems just are no longer part of the default Rails 7 template.

webpacker

Webpacker is no longer the preferred way to package up CSS according to the Rails team. However, using Javascript to package up CSS is still very popular, so webpacker shouldn’t be written off so quickly.

In particular, webpacker allows you to import CSS modules directly into your Javascript, which is the expectation of modern JS/TS-heavy applications.

You will know if you have webpacker in your app if you load your stylesheets with stylesheet_pack_tag instead of stylesheet_link_tag (which is the default).