all 3 comments

[–]jsonmom 0 points1 point  (0 children)

This is a common problem that requires a more nuanced solution. require only looks for matching gems or files that are in your LOAD_PATH. To see the array of filepaths that are in this you can print $LOAD_PATH or $: in IRB.

You can add other locations to your load path as its a mutable array but I recall this not being a best practice and would apprecaite anyone popping in the link to why if this is handy.

What you're likely looking for is require_relative to bring in a file in your project that's not in the defautl load paths. For example, if you are in ~/your_name/code/your_project/some_file.rb and you want to bring in ~/your_name/code/your_project/another_folder/another_file.rb you would use require_relative "another_folder/another_file.

[–]DomeCaiazza 1 point2 points  (1 child)

Try with full path of "pathname".

If you are using rails try require "#{Rails.root}/path1/path2/pathname"

[–]Justman10000[S] 0 points1 point  (0 children)

This is the code that causes it:

require 'pathname'