Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Bundler gem builder prebuilts module Foo in my gem root, breaking my executable. Why does this happen?

I am working with bundler and reproducing the basic gem found on ruygems, 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

working code here

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 of <b>hola mundo</b>) when I remove the module Foo and class Error in lib/foo.rb.

My 2 interconnected questions are: 1 What benefit is there in a module prebuilt into lib/foo.rb?

and 2 Why does the module break my executable? (I run bin/foo and irb spit out error)