DenicioCode
DenicioCode

Reputation: 9336

cannot load such file

I am building my own first Gem. After I created some functionality I ordered all the files like to the best practice of gem building.

I moved all the files to right folders. The executable is in bin/boss-mailer, the rest is put all in the lib folder like:

enter image description here

The executable is simple. I just set the executable to ruby and try to require the boss_mailer.rb in the lib file.

enter image description here

This cannot load my file. I can require it by using require "./boss_mailer" beginning to pointing the current path. But in other Gems on Github I see that people just use require "filename" to reference to loading file. Like here: gli gem

My Question

Do I have to pre-build the gem or something else to require my files without to point to the current path? What do I have to do require the file lib/boss_mailer' without using ./?

Upvotes: 0

Views: 714

Answers (1)

KARASZI István
KARASZI István

Reputation: 31477

Are you using Bundler? I would recommend that. Then running your binary would be simply as:

bundle exec ./bin/boss_mailer.rb

Please make sure that you configure the $LOAD_PATH correctly in your boss-mailer.gemspec correctly, but if you've followed the best practices you've probably already done that.

Upvotes: 1

Related Questions