Legacy Rails 6 Setup Notes: rbenv, Webpacker, and Git

These notes describe a Rails 6 and Webpacker-era setup. They are useful when maintaining an old application, not as a recommendation for a new Rails project. Software ages; tutorials merely pretend not to.

rbenv does not list a Ruby version

rbenv install --list gets its version definitions from ruby-build. Update it using the same installation method you originally used.

With Homebrew:

1
2
brew update
brew upgrade ruby-build

Then verify:

1
rbenv install --list

Avoid randomly running git pull inside package-manager directories. Homebrew owns those files and would like to keep the custody arrangement uncomplicated.

Bootstrap in a Webpacker-based Rails 6 app

Legacy applications may contain:

1
yarn add bootstrap jquery @popperjs/core

Webpacker’s ProvidePlugin can expose jQuery to dependencies that expect globals. The exact configuration depends on the Bootstrap major version: Bootstrap 4 used jQuery and Popper, while Bootstrap 5 removed the jQuery dependency.

For a modern Rails application, first inspect whether it uses import maps, jsbundling-rails, or another bundler. Do not paste Webpacker configuration into a project that does not have Webpacker; Rails will not be impressed by historical accuracy.

Apply .gitignore to files already committed

Adding a path to .gitignore does not untrack an existing file. Remove it only from Git’s index:

1
2
git rm --cached path/to/file
git rm --cached -r path/to/directory

Then commit the change. This does not remove the local file unless --cached is omitted.

If the file contained a secret, removing it from the latest commit is not enough. Rotate the secret and, when necessary, rewrite repository history.

Rename a local and remote branch

1
2
3
git branch -m new-name
git push -u origin new-name
git push origin --delete old-name

Update the default branch in the hosting provider before deleting the old remote branch when other users or deployments depend on it.

References