简体   繁体   中英

How do you get a list of commands available on a gem?

I just installed a gem but when I type

gem_name --help

It says:

'gem_name' is not recognized as an internal or external command

However, when I type

gem list --local

the gem shows up in the list so I know it's there - I just don't know how to see what it does.

Is there a different instruction to use to find out what commands this gem offers?

Ruby gems can optionally install executable files. When you run <gem_name> --help , you're generally running the script, if any, installed by that gem, and passing it --help as a commandline parameter. By convention, most gems with executables support this parameter and output some useful information, but it's not a requirement - and, as mentioned, there are plenty of gems that don't install any executables at all.

In this case, it appears that the gem you installed doesn't provide any scripts (or, at the very least, doesn't provide any scripts with the same name as the gem). As others have suggested, looking at the rdoc for the gem might be a good way to start; you can use the gem server command to serve up all your local gems' rdoc content. Alternately, some gems host their rdoc at Rubyforge.

What is the gem in question?

Try: gem specification <gem_name>

Alternatively consult the rdoc documentation for the installed gem.

Try this:

1- gem server

2- Point your browser to: http://localhost:8808/

Gems are tricky in that aspect. They sometimes install commands (like rails), and at other times just install code that can be 'require'd by your ruby application. The best way is to read up the doc on that gem on the internet.

The gem is usually located at some place like /usr/lib/ruby/gems/... and you may want to go in and look up what it is constituted of. At this time, I would recommend reading the online documentation.

As the other answers have stated, there isn't a direct way to do this via the gem command. In addition to the gem rdocs (which you can view using " gem server " or with bdoc - my preference), you can also look through the contents of the gem for files located in the bin folder of the gem.

gem contents somegem | grep "^bin"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM