Skip to content

Invalid Gemspec

Posted on:January 6, 2016

A minor, but frustrating bug. While working on Rogger, I came across the following problem while bundling my local Rogger into a test project:

The gemspec at /Users/siawyoung/github/rogger/rogger.gemspec is not valid. The validation error was 'rogger-0.1.1 contains itself (rogger-0.1.1.gem),
check your files list'

I was quite confused. I checked the gem file but nothing inside seemed like a reference to rogger-0.1.1.gem.

I tried building the gem:

$ gem build rogger.gemspec
WARNING:  See http://guides.rubygems.org/specification-reference/ for help
ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
    ["rogger-0.1.1.gem"] are not files

The same error happened.

It turns out this happens because the gemspec gets the list of files from the

`git ls-files -z`.split("\x0")

command. I happened to check the gem file rogger-0.1.1.gem in, which was why this error was occurrring. Removing it, then, fixed it:

$ rm rogger-0.1.1.gem
$ git commit -am "Remove rogger-0.1.1.gem"
$ git push