Java has the convienient System.getProperty("user.home") to get the user’s “home” directory in a platform-independent way. What’s the equivalent in Ruby? I don’t have a Windows box to play around with, and I feel like relying on tildes in filenames isn’t the cleanest way. Are there alternatives?
Java has the convienient System.getProperty(user.home) to get the user’s home directory in a platform-independent
Share
The
File.expand_pathmethod uses the Unix convention of treating the tilde (~) specially, so that~refers to the current user’s home directory and~foorefers tofoo‘s home directory.I don’t know if there’s a better or more idiomatic way, but
File.expand_path('~')should get you going.