Richard Stokes
Richard Stokes

Reputation: 3552

Requiring scripts is broken when using RVM

Been running into a problem ever since I started using rvm to manage my ruby installation. Whenever I want to require another class I've written, such as require 'filename', I get a require - no such file to load error when I try to run my script. If I switch back to my system ruby using rvm use system it works again, but I'm 1.8.2 as my system ruby and some features I want to use in my code are only available in 1.9.*, which I can access through rvm. How do I fix this problem?

Upvotes: 1

Views: 83

Answers (2)

coreyhaines
coreyhaines

Reputation: 833

I think you want to use require_relative

http://extensions.rubyforge.org/rdoc/classes/Kernel.html

Upvotes: 1

Eugene
Eugene

Reputation: 4879

I'm not sure this is a problem with RVM, but a problem with Ruby 1.9 not including '.' in the current path. For instance, if you are trying to require a library at './lib/file.rb', you can't do

require "lib/file"

You have to do this:

require "./lib/file"

Have you tried that syntax for your require?

Upvotes: 5

Related Questions