title: Trying to build a gem, getting a Gem::InvalidSpecificationException: "[...] are not files"
body: <p>I'm trying to build a custom gem I wrote called <code>client_package</code> but it is failing.</p>
  
  <p>My directory structure looks like this:</p>
  
  <pre><code>client_package
      Gemfile
      Gemfile.lock
      client_package.gemspec
      Rakefile
      Readme.md
      .gitignore
      .git
          ...git files...
      lib
          client_package.rb
          client_package
              version.rb
              api.rb
              ...more...
  </code></pre>
  
  <p>And my <code>client_package.gemspec</code> looks like this:</p>
  
  <pre><code># encoding: UTF-8
  require File.expand_path('../lib/client_package/version', __FILE__)
  
  Gem::Specification.new do |s|
      s.name = 'client_package'
      s.version = ClientPackage::VERSION
      s.platform = Gem::Platform::RUBY
  
      s.files = `git ls-files`.split('\n')
      s.executables = `git ls-files -- bin/*`.split('\n').map{ |f| File.basename(f) }
      s.require_paths = ['lib']
  
      # also have s.authors, s.email, s.homepage, s.summary, s.description
  
      s.add_dependency 'httparty'
      s.add_dependency 'json'
  end
  </code></pre>
  
  <p>And all my files are committed and the git state is clean.</p>
  
  <p>From within the top <code>client_package</code> directory, I run <code>gem build client_package.gemspec</code> and get this error:</p>
  
  <pre><code>ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
      [".gitignore
  Gemfile
  Rakefile
  Readme.md
  client_package.gemspec
  lib/client_package.rb
  lib/client_package/api.rb
  lib/client_package/version.rb
  lib/client_package/...more...
  "] are not files
  </code></pre>
  
  <p>This is puzzling to me, because those certainly seem to be files to me. Anyway, I figured there is some path problem if it's not seeing these files, and just doing some trial and error I discovered that if I go up a directory (one above the top-level <code>client_package</code>) and then run <code>gem build client_package/client_package.gemspec</code> it <em>does</em> appear to work at first, creating the file <code>client_package-1.0.0.gem</code>. But something is still wrong. If I then install that gem with <code>gem install client_package-1.0.0.gem</code> that also appears to work. But then this:</p>
  
  <pre><code>require 'rubygems'
  require 'client_package'
  </code></pre>
  
  <p>Returns <code>LoadError: no such file to load -- client_package</code>.</p>
  
  <p>I feel like I must be missing something small but important. Any ideas?</p>