Make sure to read the documentation. It describes how
require will search for files to load.
If the file name you pass starts with
require will treat it like a relative path based on the current working directory.
Otherwise like @arielj said you will have to make sure the directory containing the file you want to load is in the load path. There’s a lot of ways to accomplish this. Bundler is one. Zeitwerk is another. You could also just manually push directories onto the
$LOAD_PATH global variable. That’s what people did before Zeitwerk and Bundler came around.
Taking a look at your code, if you want to change the
require_relative statements to
require without relative paths, you will need to get your
lib/ directory into the load path, using one of the tools I described.