Skip to content

Instantly share code, notes, and snippets.

@pvdb
Created June 11, 2014 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvdb/8d03156d2c7d1e59b4cb to your computer and use it in GitHub Desktop.
Save pvdb/8d03156d2c7d1e59b4cb to your computer and use it in GitHub Desktop.
Get current user's home directory, even if ${HOME} isn't set in env
# as a String
HOME = ENV['HOME'] || File.expand_path("~#{Etc.getlogin}")
# as a Pathname
HOME = Pathname.new(ENV['HOME'] || File.expand_path("~#{Etc.getlogin}"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment