title: How do I test a GEM with local GEM dependencies, $LOADED_FEATURES is not pointing my local GEMs
body: <p>I have a gem called <code>KBuilder::Watch</code> which uses a bunch of GEM's that I also developed.</p>
  <p>The normal dependency management in <code>.gemspec</code> is as follows:</p>
  <pre class="lang-rb prettyprint-override"><code>spec.add_dependency 'k_builder', '~&gt; 0.0'
  spec.add_dependency 'k_builder-dotnet', '~&gt; 0.0'
  spec.add_dependency 'k_builder-package_json', '~&gt; 0.0'
  spec.add_dependency 'k_builder-webpack5', '~&gt; 0.0'
  spec.add_dependency 'k_doc', '~&gt; 0.0'
  spec.add_dependency 'k_log', '~&gt; 0.0'
  spec.add_dependency 'k_util', '~&gt; 0.0'
  </code></pre>
  <p>These GEMs have previously been installed into an ASDF environment via <a href="https://rubygems.org/profiles/klueless" rel="nofollow noreferrer">RubyGems</a> and <code>bundle install</code></p>
  <p>I have overriden this using GemFile</p>
  <pre class="lang-rb prettyprint-override"><code>gem 'k_builder'               , path: '../k_builder'
  gem 'k_builder-package_json'  , path: '../k_builder-package_json'
  gem 'k_builder-webpack5'      , path: '../k_builder-webpack5'
  gem 'k_doc'                   , path: '../k_doc'
  gem 'k_log'                   , path: '../k_log'
  gem 'k_util'                  , path: '../k_util'
  </code></pre>
  <p>I am running k_builder-watch exe using</p>
  <pre class="lang-sh prettyprint-override"><code>/Users/username/dev/kgems/k_builder-watch/exe/k_builder-watch
  </code></pre>
  <p>When I run the application and check what ruby files are loaded via the <code>$LOADED_FEATURES</code> array, all of the external dependency code in memory are coming from the installed GEMS path instead of local path.</p>
  <pre class="lang-rb prettyprint-override"><code>my_gems = %w(handlebars-helpers k_builder k_builder-dotnet k_builder-watch k_builder-package_json k_builder-webpack5 k_doc k_log k_util)
  
  loaded_files = $LOADED_FEATURES.select { |gem| my_gems.any? { |my_gem| gem.include?(my_gem) } }.sort
  
  puts loaded_files
  </code></pre>
  <p><a href="https://i.stack.imgur.com/DXyn9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DXyn9.png" alt="Remote Dependencies" /></a></p>
  <h2>I've made progress towards a solution</h2>
  <p>I have just tested this same flow from a unit test in <code>k_builder-watch</code> GEM and all files in the <code>$LOADED_FEATURES</code> array are now pointing to my local dependencies, from this I have worked out that the issue is environmental.</p>
  <pre class="lang-rb prettyprint-override"><code>RSpec.describe KBuilder::Watch::Watcher do
    let(:watch_path) { '/Users/davidcruwys/dev/kgems/k_builder-watch/.builders' }
  
    it {
      watcher = KBuilder::Watch::Watcher.new(watch_path)
      watcher.start
    }
  end
  </code></pre>
  <pre class="lang-rb prettyprint-override"><code>my_gems = %w(handlebars-helpers k_builder k_builder-dotnet k_builder-watch k_builder-package_json k_builder-webpack5 k_doc k_log k_util)
  
  loaded_files = $LOADED_FEATURES.select { |gem| my_gems.any? { |my_gem| gem.include?(my_gem) } }.sort
  
  puts loaded_files
  </code></pre>
  <p><a href="https://i.stack.imgur.com/KQeAb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KQeAb.png" alt="Local Dependencies" /></a></p>