Auto-install system dependencies for Ruby on Rails
JetThoughts Dev
Posted on September 22, 2022
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
.
Paul Keen is an Open Source Contributor and a Chief Technology Officer at JetThoughts. Follow him on LinkedIn or GitHub.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories.
Posted on September 22, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.