I am working with bundler and reproducing the basic gem found on rubygems.org, to gain a better grasp running gems as executables. I am reproducing only the necessary code here for succinctness' sake.
bundle gem foo creates the necessary gem tree. However in the skeleton of lib/foo.rb
module Foo
class Error < StandardError; end
...
end
In irb, when I run ruby -Ilib ./bin/foo, irb throws out an error:
/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require': cannot load such file -- foo (LoadError)
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require'
from ./bin/foo:3:in'`
I DO get my desired result (matching the result hola mundo when I remove the module Foo and class Error in foo.rb.
My 2 interconnected questions are thus: 1 Why is a module prebuilt by bundler into lib/foo.rb?
and 2 Why does the module break my executable?