I learned this tip from Mike Burns.
Drop into an interactive Ruby shell:
> require 'etc'
From the docs:
Etcmodule provides a more reliable way to access information about the logged in user than environment variables such as
> Etc.getpwuid.gecos.split(',').first => "Dan Croak"