1

I have a problem with require in my gem. When I user require in my main.rb like require 'folder/first' it throw error require': cannot load such file -- folder/first (LoadError)

So my question is - Why can't I require my own files inside the gem?

├── lib ├── folder │   ├── first.rb │   ├── second.rb │   ├── third.rb │   └── version.rb └── main.rb` 

The first.rb looks like this:

module MyGem class FirstClass def some_method ... end end 

The main.rb looks like this:

require 'folder/first module MyGem def run_first first = MyGem::FirstClass.new .... end end 

Gemspec:

lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'relp/version' Gem::Specification.new do |spec| ... spec.files = `git ls-files`.split("\n") spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") spec.require_paths = ["lib"] spec.bindir = "exe" spec.required_ruby_version = '>= 2.0.0' spec.add_development_dependency "bundler", "~> 1.12" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "minitest", "~> 5.0" end 

`

0

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.