title: How to reference a local gem from a ruby script?
body: <p>I need to reference a local gem from a plain ruby script, without installing the gem. On the trail of <a href="https://stackoverflow.com/questions/6444827/how-to-refer-a-local-gem-in-ruby">How to refer a local gem in ruby?</a>, i tried creating a Gemfile with the following setup:</p>
  
  <pre><code>%w(
    custom_gem
    another_custom_gem
  ).each do |dependency|
    gem dependency, :path =&gt; File.expand_path("../../#{dependency}", __FILE__)
  end
  </code></pre>
  
  <p>and the script looks like this:</p>
  
  <pre><code>require 'custom_gem'
  CustomGem::Do.something
  </code></pre>
  
  <p>When I execute this with:</p>
  
  <pre><code>bundle exec ruby script.rb
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>script.rb:1:in `require': cannot load such file -- custom_gem (LoadError) from script.rb:1:in `&lt;main&gt;'
  </code></pre>
  
  <p>If I leave out the <code> require 'custom_gem' </code>, I get:</p>
  
  <pre><code>script.rb:3:in `&lt;main&gt;': uninitialized constant CustomGem (NameError)
  </code></pre>
  
  <p>I even tried without bundler, and just writing <code>gem ... :path =>̣ ...</code> in the script itself, but without results. Is there any other way of referencing custom gems from ruby scripts, without installing the gems locally?</p>