How do I rescue from a `require': no such file to load in ruby?
rescue without arguments rescues only StandardError s. The LoadError (that is raised by a file not found) is not a StandardError but a ScriptError (see http://blog.nicksieger.com/articles/2006/09/06/rubys-exception-hierarchy). Therefore you have to rescue the LoadError explicitly, as MBO indicated.
Ruby 'require' error: cannot load such file
I just tried and it works with require "./tokenizer"
. Hope this helps.
ruby gem require_relative cannot load such file
I got this working by copying everything out of interface.rb deleting the file and recreating it. Strange why that happened.
Related Topics
Differencebetween Ruby's 'Open-Uri' and 'Net:Http' Gems
Str.Each in Ruby Isn't Working
How to Use "_Blank" or "_New" in Rails
How to Ignore a Folder in Zeitwerk for Rails 6
Ruby Pipes: How to Tie the Output of Two Subprocesses Together
Why Doesn't Relative_Require Work on Ruby 1.8.6
Undefined Method 'Name' for "Actionmailer":String
How to Find Gems That Depend on a Given Gem
How to Store an Instance Variable Across Multiple Actions in a Controller
Slicing Params Hash for Specific Values
In Ruby How to Use Class Level Local Variable? (A Ruby Newbie's Question)
Tcp Socket Communication Between Processes on Heroku Worker Dyno
How to Use Functions Like Concat(), etc. in Arel
Ruby Indented Multiline Strings
Using Bsearch to Find Index for Inserting New Element into Sorted Array
Your Ruby Version Is 2.1.0, But Your Gemfile Specified 2.0.0