brewgem -- install gems as homebrew formulas
brewgem
allows you to install any rubygem as a homebrew formula.
It works by generating a stub formula for homebrew, which looks something like this:
class Ronn < Formula
def initialize(*args)
@name = "ronn"
@version = "0.7.3"
super
end
def install
system "gem", "install", name, "--version", version, "--install-dir", prefix
end
end
This formula installs and unpacks all the dependencies under the Cellar path. So the package is completely self contained.
Dependencies
This requires a system rubygems version of 2.3 or greater There is a bug prior to 2.3 that doesn't install the full dependency tree properly when you use the install-dir flag.
sudo /usr/bin/gem update --system
Install
Option 1. Clone this repo and "bundle install". Then, to install self (brewgem) via brew, just run:
bin/brewgem install --local=.
Option 2. Brewgem is also a gem, so you can install it with:
gem install brewgem
Usage
brewgem install <gem-name> [<version>] # install from RubyGems
brewgem install --local=<path-to-local.gem> # install from local gemfile
brewgem install --local=<path-to-local-dir> # install from local gem dir
brewgem install --git=<git@github.com:project/repo.git> # install from git gem repo
brewgem install --git=<git@github.com:project/repo.git> --ref=<git-branch-or-tag> # install from specific tag or branch in git gem repo
brewgem update <gem-name> # update a gem from RubyGems
brewgem uninstall <gem-name>
BASH/ZSH Completions
To make use of completions for your gem, you need to install the
bash-completion
formula:
brew install bash-completion
And then install a gem with the completion files in the following locations:
-
A directory named either
completion
orcompletions
with the file being the name of the gem appended with the completion type.For example:
completions/tmuxinator.bash
-
A file somewhere in your repo named
<your_gem_name>_completion.zsh
.
Files with .bash
and .sh
will be associated with bash and files ending in
.zsh
will be associated with zsh.
Philosophy
This is not for installing development libraries, but for standalone binary tools that you want system wide.
Troubleshooting
If your seeing build errors similar to this:
==> Fetching opsicle from gem source
==> gem install /Library/Caches/Homebrew/opsicle-0.4.2.gem --no-rdoc --no-ri --no-user-install --install-dir /usr/local/Cellar/opsicle/0.4.2 --bindir /usr/local/Cellar/opsicle/0.4.2/bin
make: *** [generator.bundle] Error 1
Gem files will remain installed in /usr/local/Cellar/opsicle/0.4.2/gems/json-1.8.1 for inspection.
Results logged to /usr/local/Cellar/opsicle/0.4.2/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting
You probably have xcode 5.1 installed which changed the way the compilers handle flags.
You'll need to set ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future
before installing.
You may want to add this to your profile so you don't have to set it each time.