[Rubygems-developers] [ rubygems-Patches-28149 ] Suggest similar gem names when install fails to find any matches

noreply at rubyforge.org noreply at rubyforge.org
Wed Apr 28 01:02:27 EDT 2010


Patches item #28149, was opened at 2010-04-27 22:02
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=577&aid=28149&group_id=126

Category: `gem install`
Group: v1.3.x
Status: Open
Resolution: None
Priority: 3
Submitted By: Justin Collins (presidentbeef)
Assigned to: Nobody (None)
Summary: Suggest similar gem names when install fails to find any matches

Initial Comment:
This patch adds a list of suggestions when a gem fails to install. For example:

$ gem install rcvo
ERROR:  Could not find a valid gem 'rcvo' (>= 0) in any repository
        Possible alternatives: rcov, rcv


Some notes:
-Only makes suggestions if domain is not :local
-Only makes suggestions if non-default version is specified
-No idea how well this works with Unicode

Arbitrary design decisions, which can easily be changed:
-There is an arbitrary limit (12) on the number of suggestions
-If this limit is reached, "..." will be appended to the suggestion list
-Underscores and hyphens are ignored
-Case is ignored
-Because of the two above points, "perfect" matches may not be perfect
-If a "perfect" match is found, only that suggestion is returned
-Similarity is based on the Damerau–Levenshtein distance algorithm
-There is a limit on how "different" the names may be. Currently, this is half of the specified name length. This makes more sense for short search names and less sense for long names
-Matches will be made to gems that have the specified gem name as a prefix
--Prefix matching is skipping for names with length < 4
---This is because the lower limit for a name of length 3 will be 1, and thus prefix matching will be reported as a perfect match (0). This is clearer in the code, and could probably be changed

Time taken searching for suggestions is naturally dependent on the number of gem names that need to be checked and the size of the specified name. I've found the time tolerable, once I discovered I still had RubyForge and GitHub as gem sources and removed them.

All tests appear to be passing.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=577&aid=28149&group_id=126


More information about the Rubygems-developers mailing list