2

I just installed the unicode-gem, which is called "unicode" but I cannot require it with require "unicode".

There was a command to retreive the name of a gem you need for a require, but I forgot it and cannot find it with google.

How was this again?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
Joern Akkermann
  • 3,542
  • 8
  • 33
  • 41
  • `gem specification unicode` ? – Zabba Mar 17 '11 at 22:46
  • 3
    [I have a gem installed but require 'gemname' does not work. Why?](http://stackoverflow.com/questions/132867/i-have-a-gem-installed-but-require-gemname-does-not-work-why) – Zabba Mar 17 '11 at 23:00
  • the require command works on files so the correct require will take the name of one of the files in your gem's folder. this doesn't answer your question, but it may help as a hint of what to look for. – Doug Mar 18 '11 at 19:44

1 Answers1

2

It seems like that should be part of the gem spec., so I've been nosing around in some of the rubygems gem's modules to see if there was a way to programmatically find out the right require string. So far I haven't found anything. It seems like a hole to me; I've run into the problem you're talking about, and it's a pain. The gem-writers are the ones who know the string, so it should be in the *.gemspec file.

My recommendation is to run gem env at the command-line, and cd into the directories displayed for "GEM PATHS", then into the gems directory, followed by the directory for the gem in question. Inside that directory look for README or similar files and see what they say. If nothing is found run:

grep -r require *

then look through the results for likely candidate strings. If there's a "test" directory, change the "*" to "test" first, to reduce the results to more-likely hits.

For instance, the Net::SSH gem is called "net-ssh", but it's gem is required using net/ssh. Searching with grep showed a lot of instances of require 'net/ssh'.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303