Productively Distracted
Posted Tuesday March 5, 2013 around 4:30 PM

I recently made some changes to my gem Elster. After releasing it and running bundle on my rails project, I got the error:

$ bundle install
  ... Lots of Output ...
Installing elster (0.1.1)
Gem::InstallError: attempt to install file into /Users/jwebb/src/bigjason/elster/doc/_index.html
An error occurred while installing elster (0.1.1), and Bundler cannot continue.
Make sure that `gem install elster -v '0.1.1'` succeeds before bundling.
Raw

After a bit of digging around I figured out the problem was that the local folder /doc was being included in my gem. I was setting files in my .gemspec like this:

gem.files = Dir["#{File.dirname(__FILE__)}/**/*"]
Raw

Which was picking up all kinds of trash that gets left around during building and testing a gem. After a little googling around for a best practice, I found a much nicer way on http://yehudakatz.com. You can see his full explanation and code here, but the basic solution looks like this:

gem.files = Dir.glob("{bin,lib,test}/**/*") + %w(LICENSE README.md Rakefile)
Raw

After releasing a new version with that small tweak, Elster installs just fine once again and still doesn't rely on an expensive git ls-files. Hope this saves someone else some time.

blog comments powered by Disqus