Note that there are some explanatory texts on larger screens.

plurals
  1. POBundler.require doesn't require dependencies which are in the gemspec
    primarykey
    data
    text
    <p>I have an application using bundler which works fine at the moment but I have to run it out of the project's bin directory. Now I'm trying to convert it to a gem.</p> <p><code>bin/myexecutable</code> (no changes):</p> <pre><code>#!/usr/bin/env ruby require 'mygem' MyGem::MyExecutable.new.main(ARGV) </code></pre> <p><code>lib/mygem.rb</code> (no changes):</p> <pre><code>require 'rubygems' require 'bundler/setup' Bundler.require require 'mygem/version' require 'mygem/my_executable' </code></pre> <p><code>mygem.gemspec</code> (new):</p> <pre><code># coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'mygem/version' Gem::Specification.new do |spec| # ... omitting boilerplate specs of gem ... spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] spec.add_development_dependency 'bundler', '~&gt; 1.3' spec.add_development_dependency 'rake' spec.add_runtime_dependency 'bindata' end </code></pre> <p><code>Gemfile</code> (moved dependencies to mygem.gemspec):</p> <pre><code>source 'https://rubygems.org' gemspec </code></pre> <p>When I install the gem and attempt to run the executable, I get:</p> <pre><code>.../resource_file.rb:2:in `&lt;class:ResourceFile&gt;': uninitialized constant ResourceFile::BinData (NameError) </code></pre> <p>Copying the dependencies back to <code>Gemfile</code> makes it work again, but now I have redundant declarations of the same dependencies in two locations.</p> <p>Why doesn't it work when using the <code>gemspec</code> declaration?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload