I have a custom gem which is built on the following structure of files:
something/common/searchcommon.gemspec
something/common/lib/searchcommon.rb
something/common/lib/commonfiles/scommon.rb
something/common/lib/commonfiles/token_stream.rb
something/common/lib/commonfiles/rbbi.rb
My gemspec file looks like this:
Gem::Specification.new do |s|
s.name = 'searchcommon'
s.version = '0.0.0'
s.date = '2012-04-28'
s.summary = "Search Common classes"
s.description = "Contains the common classes for search"
s.authors = ["some author"]
s.email = 'x@x.com'
s.files = ["lib/searchcommon.rb","lib/commonfiles/scommon.rb","lib/commonfiles/rbbi.rb","lib/commonfiles/token_stream.rb"]
end
I'm able to build and install the gem without issues.
It also works on irb:
>> require 'searchcommon'
=> true
However, I have a script which will need this gem. The script includes the gem as follows:
#!/usr/local/bin/ruby
require 'rubygems'
require 'searchcommon'
The error I'm getting throws the following stack trace:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- scommon (LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/searchcommon-0.0.0/lib/commonfiles/rbbi.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/searchcommon-0.0.0/lib/searchcommon.rb:1
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60:in `require'
from ./mapper.rb:3
The erroneous line is a "require 'commonfiles/rbbi'" inside lib/commonfiles/searchcommon.rb
The line inside rbbi.rb which has this error is "require 'scommon'" which is also present in the same folder.
I'm not able to understand why this wouldn't work in the script when I'm able to use the gem just fine with IRB.
I had a look at this question on SO but it didn't quite fix the same problem.
Any help would be appreciated.
Edit: Removed some confusing file names and replaced them.