title: Ruby Unresolved specs during Gem::Specification.reset with installed gems
body: <p>I have a gem which we'll call  <code>mygem</code> that has an executable used as a CLI tool.</p>
  
  <p>The file <code>mygem/bin/mygem</code>:</p>
  
  <pre><code>#!/usr/bin/env ruby
  lib = File.expand_path('../lib', __FILE__)
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
  require 'bundler/setup'
  ....code goes here....
  </code></pre>
  
  <p><code>mygem.gemspec</code>:</p>
  
  <pre><code>Gem::Specification.new do |gem|
    gem.bindir      = 'bin'
    gem.executables = ['mygem']
  end
  </code></pre>
  
  <p>Build and install:</p>
  
  <pre><code>gem build mygem.gemspec
  gem install mygem-0.1.0.gem
  &lt;optionally bundle install, but that won't fix the error&gt;
  </code></pre>
  
  <p>And, at the end, I can successfully call <code>mygem</code> from the command line and the script runs.</p>
  
  <p>The issue is that it can only run from a folder that does <em>not</em> contain a <code>Gemfile</code>. When doing otherwise, the system outputs an error:</p>
  
  <pre><code>WARN: Unresolved specs during Gem::Specification.reset:
        json (&gt;= 0)
  WARN: Clearing out unresolved specs.
  Please report a bug if this causes problems.
  Could not find differ-0.1.2 in any of the sources
  Run `bundle install` to install missing gems.
  </code></pre>
  
  <p>The actual gems that show up in this error message vary depending on the Gemfile in the current directory.</p>
  
  <p>Running <code>bundle exec mygem</code> suppresses part of the error message, but still fails to execute unless <code>bundle install</code> is run on the <em>other</em> application's Gemfile:</p>
  
  <pre><code>Could not find differ-0.1.2 in any of the sources
  Run `bundle install` to install missing gems.
  </code></pre>
  
  <p>How can this be fixed?</p>