Getting ruby require to work properly


#1

I just joined today, and I set up a project in Ruby. (I used the Blank template, not the Ruby template). The first version had all my functions in a single file, and that worked fine. However, I then moved some of the functions into another file called “common.rb”, and put a require “common” line in the main file. For some reason, this doesn’t work; when I try to run it, I get the following error:

/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in require': cannot load such file -- common (LoadError) from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from /home/ubuntu/workspace/probs.rb:1:in `’

How do I get require working correctly?


#2

It will be easier to help if you show us your workspace tree as well as your code.


#3

Here’s an image of the workspace. I also tried moving common.rb into the root folder to see if that would help. It did not.


#4

Ah, I figured it out: using require “/home/ubuntu/workspace/lib/common” works.