Skip to main content

Overview

This example demonstrates envcheck configuration for a Ruby on Rails application. It validates Ruby and Bundler versions, optional Node.js and Yarn for asset compilation, environment variables with pattern matching, and Rails-specific files.

Configuration

.envcheck.yaml

What This Checks

Tools

  • ruby >=3.0.0: Ensures compatibility with Rails 7.x and modern Ruby features
  • bundle: Validates Bundler is available for gem dependency management
  • node (optional): Required for Rails asset pipeline and JavaScript compilation
  • yarn (optional): Modern JavaScript package manager for Rails with Webpacker/jsbundling

Environment Variables

  • DATABASE_URL (required): Database connection string - critical for Active Record
  • RAILS_ENV (optional): When set, validates it’s a valid Rails environment (development/test/production)

Ports

  • 3000: Rails default development server port for rails server

Files

  • Gemfile: Ruby dependencies manifest - required for all Rails projects
  • config/database.yml: Database configuration - Rails standard location
  • .env (optional): Environment variables file - recommended but not required

Expected Output

Tips for Rails Projects

Use dotenv-rails gem to automatically load .env files in development and test environments. Add .env to .gitignore and commit .env.example as a template.
The pattern validation ensures RAILS_ENV only accepts standard environments. If you use custom environments like “staging”, update the pattern to include them.
Node.js and Yarn are marked optional because not all Rails apps need JavaScript bundling. Rails 7+ can work with import maps, eliminating the Node.js dependency.

Common Variations

Rails API-Only Mode

Simplified checks for API applications:

Rails with Hotwire/Turbo

Modern Rails with minimal JavaScript:

Rails with Webpacker/esbuild

Full JavaScript toolchain:

Rails with Sidekiq

Background job processing:

Rails Production Deployment

Production environment validation:

Multi-Database Rails App

Rails 6+ with multiple databases:

Rails-Specific Considerations

Database URL Format

Common DATABASE_URL patterns for Rails:
  • PostgreSQL: postgresql://user:password@localhost/mydb
  • MySQL: mysql2://user:password@localhost/mydb
  • SQLite: sqlite3:db/development.sqlite3

Ruby Version Managers

Popular tools for managing Ruby versions:
  • rbenv: Lightweight Ruby version management
  • rvm: Ruby Version Manager with gemsets
  • asdf: Multi-runtime version manager
Consider adding .ruby-version file:

Credentials and Security

Rails 5.2+ uses encrypted credentials:

Asset Compilation

For apps with compiled assets, ensure NODE_ENV:

Learn More