JT Book a call

Blog

Auto-install system dependencies for Ruby on Rails

Published

1 min read

Auto-install system dependencies for Ruby on Rails

Let’s integrate Homebrew into our Ruby on Rails Project local set up.

There is a convention for Ruby on Rails projects to use bin/setup to set up and install/update required dependencies. But by default, it does not include system dependencies.

We are going to use the Homebrew Bundle tool for this.

First, we need to have a Brewfile with:

# Redis - For ActionCable support (and Sidekiq, caching, etc.)
brew "redis"
    
# PostgreSQL - brew install postgresql
brew "postgresql"
    
# Overmind (requires tmux)
brew "tmux"
brew "overmind"
    
# Imagemagick or libvips - for processing images (avatars, file uploads, etc.)
brew "vips"
    
# Yarn - for installing Javascript dependencies
brew "yarn"

Then, in bin/setup, we are going to add:

puts "== Installing system dependencies =="
if system('[[ (-x "$(command -v brew)") ]]') # Is Homebrew available?
  system("brew bundle check --no-lock --no-upgrade") || system!("brew bundle --no-upgrade --no-lock") # install if there are missed dependencies
end

I prefer to add it in the beginning before installing other dependencies.

These will help new onboarding set up development with one command only. Reduces the number of instructions from README.

Read next

Tell us whatyou need built

JetThoughts has been building software since 2008. Book a call, or write to sales@jetthoughts.com. You'll leave the call with a written one-page scope within 2 working days.

#01 Paul Keen
Paul KeenFounder

A 30-minute call; pick a time.