I’m new to gem development. I just completed a gem for use with a Rails
3.0.7 project. The gem itself passes its tests. I’ve listed the gem in
the Rails project’s Gemfile…
Unfortunately, Rails is choking on some requires in my gem. Here is what
I get in Rails:
activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require’:
no such file to load – zip_code/config.rb (LoadError)
Meanwhile, the lib directory in the gem consists of zip_code.rb
and /zip_code, where zip_code.rb contains the key lines:
I’m new to gem development. I just completed a gem for use with a Rails
3.0.7 project. The gem itself passes its tests. I’ve listed the gem in
the Rails project’s Gemfile…
Unfortunately, Rails is choking on some requires in my gem. Here is what
I get in Rails:
activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require’:
no such file to load – zip_code/config.rb (LoadError)
$LOAD_PATH.unshift(File.dirname(FILE))
Try getting rid of that line. Do you have a .gemspec file?
I’ll leave my gemspec farther below – in case someone sees something
above right away – but I still get the kind kind of error when this gem
is installed in my Rails 3.0.7 app…
gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in require': no such file to load -- zipcode/config.rb (LoadError) ... ruby-1.9.2-p290/gems/zipcode-0.0.1/lib/zipcode.rb:1:in<top
(required)>’
I’m using rvm 1.9.2 and Bundler in my attempt to create my first working
gem…now here’s the gemspec…
Gem::Specification.new do |s|
s.name = “zipcode”
s.version = Zipcode::VERSION
s.authors = [“Grar”]
s.email = [“[email protected]”]
s.homepage = “”
s.summary = %q{Provides city and state pair and zip data, and vice
versa}
s.description = %q{Cities in states and their zip codes}
Thanks to Luis’s reference to the original rubygems guide, I was able to
build a simple gem that worked with my Rails 3.0.7 project. So, I
realized there was something wrong with my use of bundler in creating
gems.
The problem was that I was not managing the gem’s development with git
after the initial automatic commit with gem bundler. Thus, when I
executed ‘git ls-files’ at the command line, I saw that new files, like
lib/zipcode/config.rb, were not being loaded to the gem specification’s
file list when gem bundler’s ‘rake install’ was executed.
I guess a useful takeaway from this is that Gem::Specification.files is
a vital part of the dependency loading for a gem…
Grar
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.