require error in ruby gem

720 Views Asked by At

I'm working on a Ruby gem and I'm getting an odd error. I have previously released this gem without too much trouble. I added some methods / refactored some code and wanted to release a subsequent version (from 1.1 to 1.2).

For reference, the name of the gem is Intervallum, (the word 'interval' in Latin).

I'm getting a 'require' error that's been stumping me.

The folder tree is:

.
├── Gemfile
├── LICENSE
├── README.md
├── intervallum-[version].gem
├── intervallum.gemspec
└── lib
    ├── intervallum
    │   ├── module.scroll.rb
    │   └── module.spell.rb
    └── intervallum.rb

In lib/intervallum.rb I tried Dir.glob, Dir['./lib/intervallum/*'] and require '../intervallum/lib/intervallum/module.spell.rb' and what happens for each one is:

Locally, after gem build intervallum.gemspec and gem install intervallum-[version].gem, I boot up irb and require intervallum and it works fine.

  • push to RubyGems
  • remove the local copy
  • install from RG
  • load up in irb I get load errors or it cannot find class of a helper class

I'm not sure why this keeps occurring, or if there's something that I'm missing as to why this keeps occurring but any advice would be much appreciated.

1

There are 1 best solutions below

1
On

The problem is that you are not including those files in the gem when it gets packaged. Your gemspec specifies that only the lib/intervallum.rb file will be included in the gem:

s.files   = ["./lib/intervallum.rb"]

Change that line to include all files in lib. It's also a good idea to include the gemspec.

s.files = Dir['lib/**/*', 'intervallum.gemspec']