Ruby 'require' error: cannot load such file

后端 未结 13 1516
抹茶落季
抹茶落季 2020-12-02 05:07

I\'ve one file, main.rb with the following content:

require \"tokenizer.rb\"

The tokenizer.rb file is in the same directory and it

13条回答
  •  执念已碎
    2020-12-02 05:55

    Another nice little method is to include the current directory in your load path with

    $:.unshift('.')
    

    You could push it onto the $: ($LOAD_PATH) array but unshift will force it to load your current working directory before the rest of the load path.

    Once you've added your current directory in your load path you don't need to keep specifying

     require './tokenizer' 
    

    and can just go back to using

    require 'tokenizer'
    

提交回复
热议问题