There are instances where I would like to revert and uninstall all previous gem installations.
For instance, I needed to assist a friend migrate their rails developm
Use either
$ gem list --no-version | xargs gem uninstall -ax
or
$ sudo gem list --no-version | xargs sudo gem uninstall -ax
Depending on what you want, you may need to execute both, because "gem list" and "sudo gem list" provide independent lists.
Do not mix a normal "gem list" with a sudo-ed "gem uninstall" nor the other way around otherwise you may end up uninstalling sudo-installed gems (former) or getting a lot of errors (latter).