How to check versions of gems in Heroku

Recently I got stuck trying to fix a problem in Heroku, a slick cloud-based Ruby hosting service. The problem involved gems that I had added to my app’s private gem repository. I had to check the versions of the gems in the repository, but Heroku’s documentation on gem management didn’t provide any suggestions.

Turns out, the trick is to use Heroku’s console command, and then use the Ruby Gem command. To open a new console session, fire up a terminal and enter:

heroku console

Then list the versions of the gems in your private repo, by enclosing the gem list command in backticks. (On Macs, the backtick key is in the upper left corner of the keyboard. I know, it took me a few seconds to find it as well.)

`gem list`

Since Heroku has many built-in gems, you’ll probably want to pipe through grep to find what you want:

`gem list | grep foo`

And you’re off to the races!