How to care for finished ruby programming items

A finished Ruby program is not a museum piece. It depends on a Ruby runtime, a set of gems, environment variables, files and often an external service. Care means keeping those parts stable, recorded and tested so the item still runs when you return to it in three months or three years.

Put every finished item under version control

Use Git even for a 40-line script. Create a repository, commit the first working version, then tag it v1.0.0. Commit Gemfile.lock as well as the code; the lock file records exact gem versions. Keep one remote copy outside your laptop. Commit small changes with messages that explain why, not just “update”. If the item has secrets, keep them in environment variables or a local .env file that is ignored; never commit passwords or API keys.

Record runtime, dependencies and handover notes

Write down the Ruby version the item expects. A .ruby-version file containing a version such as 3.2.2 is enough for many beginners; a Gemfile with ruby "3.2.2" is clearer. The README should state the run command, required environment variables and any external service. Record the last date you checked the item. If you use a database, note the version and how to recreate it. Add one line about what to try first if it fails. Keep this note under one page and update it after every change. Future you will not remember why a particular gem is pinned or why a file path is absolute.

Set a simple maintenance rhythm

A finished item needs a calendar entry, not constant attention. Use a 90-day review: open the repository, read the README, run the program, run the tests, and check for security alerts. Once every 30 days, run bundle outdated and note what has changed. Do not update everything on a whim. A good default is patch-level updates monthly, minor updates quarterly, and major updates only when you have time to test. Put the next review date in the README.

Keep a smoke test that takes under 60 seconds

You do not need full coverage to care for a small finished item. Keep one smoke test that exercises the main path: start the program, feed it a known input, and check the output or exit status. Keep the whole test suite under 5 minutes so you will actually run it. Before any dependency change, run the tests on the current version. After the change, run them again. If you have no tests, write a shell script or Ruby script that performs the same check and commit it.

Update dependencies one at a time

Run bundle outdated every 30 days. Pick one gem, read its changelog, update it, run the smoke test, and commit. If the test fails, revert that commit and try a smaller update. Use bundle update --conservative gem_name to avoid moving unrelated gems. Keep the lock file under version control and never delete it to “fix” an install problem unless you are prepared to retest every dependency. For major Ruby upgrades, create a branch, update the .ruby-version file, install, test, and merge only when the smoke test passes.

Back up the code and the releases

Use the 3-2-1 rule: at least 3 copies, on 2 different media, with 1 copy off-site. For most beginners, that means the working repository, a remote repository, and a periodic archive. Keep the two most recent tagged releases as downloadable archives. Test a restore every 6 months by cloning the repository into a fresh folder and running the smoke test. A backup you have never restored is only a hope. Keep archives for 12 months if the item is still in use.

Diagnose a finished item that suddenly stops working

Symptoms: the program ran last month, but now exits with an error before doing any work. Likely causes, in order: a changed Ruby version, a missing environment variable, a moved file, an updated gem, or a dependency that expects a different lock file. Fix: read the first error line, then run ruby -v and compare it with .ruby-version. Run bundle check; if it fails, run bundle install and check that Gemfile.lock is present. Run the program through bundle exec so it uses the pinned gems. If the error mentions a missing key or path, restore the environment variable or file. If a recent update caused the failure, revert that commit, confirm the smoke test passes, then retry the update on a branch.

Retire an item cleanly when care is no longer sensible

Not every finished item deserves indefinite maintenance. If it relies on an unsupported Ruby version, has unpatched security warnings, or has not been used for 12 months, retire it deliberately. Tag the final working release, archive the repository and release files, write a one-paragraph note explaining why it was retired, and make the repository read-only. Do not leave it half-updated with a broken lock file. Clean retirement is a form of care.

FAQ

How often should I check a finished Ruby item?

Every 90 days for a full review and every 30 days for a quick dependency check. If the item handles personal data or runs on the public internet, shorten the dependency check to every 14 days and apply security patches promptly.

Do I need to update every gem?

No. Update security-relevant gems first, then patch versions monthly, then minor versions quarterly. Leave major versions until you can test them on a branch. Keeping a known-good Gemfile.lock is often safer than chasing every release.

What if I no longer have the original Ruby version?

Install a supported Ruby version, create a branch, update the .ruby-version and Gemfile, run bundle install, and fix the smoke test one error at a time. If the item is only a few hundred lines, this is usually a short job. If it depends on an unsupported database or service, archive it instead of forcing an upgrade.