rubyconvict / bundler-gemlocal

Local Gemfile solution that works

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bundler-gemlocal

Local Gemfile solution that works

Overview

By using bundler-gemlocal developers can have their own custom Gemfile, called Gemlocal by default, in addition to team-wide Gemfile. The solution is easy to use and ensures no issues with Gemfile.lock.

Setup

  1. Download bundler-gemlocal.sh into your home directory:
$ cd
$ curl https://raw.githubusercontent.com/dadooda/bundler-gemlocal/master/bundler-gemlocal.sh -O
  1. Edit your user's shell startup files to source bundler-gemlocal.sh. I recommend .bashrc. If you don't have one, edit .profile:
$ echo -e "\n. bundler-gemlocal.sh" >> .bashrc
  1. Reload your shell (Mac users: open new Terminal window). Then check that b function is available:
$ type -t b
function

Usage

  • b is a Gemlocal-aware alias to bundle.
  • bx is a Gemlocal-aware alias to bundle exec.

Examples:

$ b install --path vendor/bundle
$ b check
$ bx gem list -l
$ bx rails console
etc.

Project setup example

  1. Cd to your project directory:
$ cd /path/to/project
  1. Edit .gitignore:
/Gemlocal
/Gemlocal.lock 
  1. Edit config/boot.rb or the file which initializes Bundler in your project:
ENV["BUNDLE_GEMFILE"] ||= File.exists?(fn = File.expand_path("../../Gemlocal", __FILE__)) ? fn : File.expand_path("../../Gemfile", __FILE__)
  1. Edit Gemlocal:
# Source the main Gemfile.
eval_gemfile File.expand_path("../Gemfile", __FILE__)

group :development do
  # Console enhancements etc.
  gem "irb_hacks"
  gem "ori"
  gem "rdoc"
  gem "wirb"
  # etc.
end
  1. Install the local bundle for the first time:
$ b install
  1. Add Gemlocal.example:
$ curl https://raw.githubusercontent.com/dadooda/bundler-gemlocal/master/Gemlocal.example -O
  1. All done! From now on, keep editing both Gemfile and Gemlocal as you like. Then do a b install and it'll sort everything out for you.

Why not Gemfile.local?

  1. Because I like this:
$ ls -1 Gem*
Gemfile           # o
Gemfile.lock      # o
Gemlocal          # -
Gemlocal.lock     # -

more than this:

$ ls -1 Gem*
Gemfile               # o
Gemfile.local         # -
Gemfile.local.lock    # -
Gemfile.lock          # o

Legend: (o: in the repo, -: not in the repo).

  1. Because "Gemlocal" is both a term and a filename, just like "Gemfile". It's more documentation-friendly.
  2. Because the blogs are full of half-working Gemfile.local recipes which will cause you nothing but pain. Find this page by the word "Gemlocal" and stay trouble-free!

Cheers!

Feedback of any kind is highly appreciated.

— Alex Fortuna, © 2015-2016

About

Local Gemfile solution that works


Languages

Language:Shell 100.0%