The Need for bin/start
Getting started with a new project should be as simple as possible, even for someone who is not technical. As a maintainer, you must make sure that anyone can clone your project and get it up and running in a few minutes.
After you clone a project, you should follow two steps:
In this example, the project is a web application, but it works for other projects too.
You should have a small bash script called
bin/setup in every project. You
could use Ruby for the script if that’s
what you prefer.
Rails has had a
bin/setup since 2014 and so should your project! This is the default ./bin/setup in a Rails application.
Thoughtbot wrote a great article about
At OmbuLabs , one of our latest
looks like this:
In order for our script to work, you must have a
.env.sample file that
has some default values for your
.env file. Every project you start must
.env file with environment configuration. Why?
We use Ruby for our setup script because all of our development environments have been setup with this script: OmbuLabs Setup
If you are using Rails, starting an application is simple:
But, what if you want to use something else? Let’s say you want to use Sinatra with Shotgun . Then you would need to start the server like this:
If you are using Bundler , then you would need to run it like this:
bundle exec shotgun config.ru
What if you want to use Foreman ?
You get the point. There are way too many ways to start a web application. We
need to standardize this into something flexible like
One of our latest
bin/start scripts looks like this:
From now on, all the web applications that we build at OmbuLabs will be able to get started like this:
It won’t matter if we use Foreman, Sinatra,
Cuba , Rails, Shotgun, or whatever.
bin/start will know how to get the application started in a development
I love how simple it can be to tell anyone to clone the project and run these steps:
cd path/to/project ./bin/setup ./bin/start
A web designer that has no experience with Ruby/Rails can setup and start a web application in a few minutes.
I’m a big fan of Convention over Configuration . Also, I hate it when it takes me half a day to setup a new application in my environment. It should never take more than a few minutes.