LJAK
LJAK

Reputation: 21

Gems not loading in Ruby (perhaps due to path)

After successfully installing the tagfile gem, I try to include it using

require 'tagfile'

and see this error:

cannot load such file -- tagfile

I think that this may have to do with ruby running in a different environment than my gem command. It looks like gem uses

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby

whereas ruby is in /bin/ruby

Upvotes: 0

Views: 65

Answers (1)

Martin Konecny
Martin Konecny

Reputation: 59691

My current approach for this:

$ which gem
/usr/bin/gem
$ less /usr/bin/gem

Now look at the first line. That's the ruby interpreter gem is using, and will install your gems in a way so that only this version of the interpreter will find them.

You can either:

  1. Use the same interpreter as your gem command is using.
  2. Try using the same version of gem as your default interpreter. Usually gem is a symbolic link to gem1.9.3, gem2.0, gem2.1 etc so you can substitute one of those commands with the version suffixed instead.

Upvotes: 1

Related Questions