Impulso Impulso - 1 year ago 127
Ruby Question

Error kernel_require.rb:55:in `require': cannot load such file when trying to run ruby program

So, it seems like ruby isn't able to find gems that are installed? The error:

require': cannot load such file -- activesupport (LoadError)
from /Users/userName/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
from test.rb:3:in `'

I had ruby installed via RVM and brew on my Mac (El Capitan). I don't remember what I had done when I started getting this error when trying to run my ruby program. At the top of my program I have require 'json' and require 'rest-client', and require 'activesupport' Nothing abnormal there.

After a lot of googling, I ended up doing rvm implode and removing the .rvm files from my computer to completely uninstall rvm. I then tried installing ruby via brew, but was getting the same error. I then uninstalled the the brew version of ruby, and installed with rbenv. Still got the same error, but this time with the rbenv path to the kernal_require.rb file instead of the brew or rvm paths that it had showed before.

So something tells me that this is not something to do with rvm or brew or rbenv because I was getting the same error with the versions of ruby I tried for each one. The gems are installed. Why isn't it able to load them? Uninstalling and reinstalling the gems didn't help. I had to reinstall them anyway every time I uninstalled and reinstalled ruby.

gem env home returns this:


brew config returns this for ruby:

Ruby: /Users/userName/.rbenv/shims/ruby => /Users/userName/.rbenv/versions/2.3.0/bin/ruby

I have these included in my PATH:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

ruby -v returns this:

ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]

I've checked for spaces in the file path, I've tried installing bundler and installing gems that way, but I'm still getting the same issue. What else can I look at to solve this problem?

Answer Source

You use

gem 'activerecord'

in the gemfile.

require 'active_support/all'

is used in the program.

It's slightly annoying when gems do this, but you can't always assume the files you require have the same name as in the Gemfile.