gem list rails
used to match everything that began with "rails" (and the documentation still claims it works that way) but at some point it started matching everything that includes rails anywhere in the name. This can get ridiculous, as there are (at the moment I write this, but I'm sure it goes up practically by the hour) 2,764 items that match "rails":
gem list rails --remote | wc -l
2764
Can Rubygems be made to only return exact matches by default? I don't see any commandline switches that force an exact match. Perhaps a setting in ~/.gemrc
?
Obviously I can do this by piping the output to other utilities, but that's kind of a pain to do every time you just want to (e.g.) check the latest version of a gem, and it's a lot slower, and forces you to stop and think about a detail that (IMO) is a distraction from whatever problem you're working on.
gem list rails --remote | grep '^rails '
Is there a good way to make this the default?
Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.
GEMNAME - name of the gem to print information about.
Press Ctrl+Space to show the available gem executables. In this field, type the command line arguments of the script. Specify the working directory used by the running task. For example, this option is in effect when the running script loads other scripts by relative paths.
Gemfile - A format for describing gem dependencies for Ruby programs. A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code.
You are basically entering a regex on the command line, so
gem list -r ^rails$
does an exact search without piping. I'm using rubygems 2.0.6 and 2.4.5 and it worked on both versions.
I couldn't find anything to put in .gemrc, though. You could easily set up a wrapper shell script for your most common case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With