Skip to content

Instantly share code, notes, and snippets.

@rosemarydotworld
Last active September 7, 2015 19:22
Show Gist options
  • Save rosemarydotworld/b57ded45202a097023b5 to your computer and use it in GitHub Desktop.
Save rosemarydotworld/b57ded45202a097023b5 to your computer and use it in GitHub Desktop.
How to patch Hammer's Gems

Recently my team ran into an issue with Hammer stemming from its slightly-out-of-date Sass gem; we were trying to install the latest version of Bourbon Neat, and Hammer's 3.2 era version of Sass was balking at the !global flag introduced in 3.3. Rather than reverse engineer Neat's Sass or use an earlier (read: inferior) version, I went about patching the gem, which is not so hard a process, it turns out. I'll demonstrate the procedure with Sass as my example.

Disclaimer: I know just enough to realize that this is a fairly stupid hacky thing to do that will likely stop working when Hammer updates–assuming they don't update the Sass gem themselves.

Step 1: Procure and locate the gem we want

In your terminal, install your desired gem. in my case:

gem install sass -v 3.3.6

After installation, locate the gem file itself. This path probably varies depending on your ruby version. For me:

cd ~/.gem/ruby/2.0.0/cache

You might need to unpack the gem before you move it:

gem unpack sass

Step 2: Copy the gem to Hammer's gems directory

In my case:

sudo cp sass-3.3.6.gem /Applications/Hammer.app/Contents/Resources/Gem/vendor/production/bundle/ruby/2.0.0/gems

Again, the path probably varies; explore on your own and find your own unique special snowflake path.

Step 3: Edit Hammer's setup script

As far as I can tell, Hammer runs a setup script when it opens to make sure it's got all its ducks in a row. It's mostly a big list of gems that it wants to require, which is exactly what we want to futz with. The script is called setup.rb and for me it lived here:

/Applications/Hammer.app/Contents/Resources/Gem/vendor/production/bundle/bundler/setup.rb

Find the offending gem version and overwrite with the shiny new version. In my case:

$:.unshift File.expand_path("#{path}/../#{ruby_engine}/#{ruby_version}/gems/sass-3.3.6/lib")

Step 4: Restart Hammer and rejoice

@krstivoja
Copy link

Thanks,
worked like a charm 👯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment