Skip to content

Commit

Permalink
use HOME or HOMEPATH/HOMEDRIVE to find home on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
dickeyxxx committed Nov 20, 2014
1 parent b1c1522 commit a05c2ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ If the file doesn't exist, Netrc.read will return an empty object. If
the filename ends in ".gpg", it will be decrypted using
[GPG](http://www.gnupg.org/).

Read the user's default netrc file (`$HOME/.netrc` on Unix;
`%HOME%\_netrc` on Windows):
Read the user's default netrc file. On Unix: `$HOME/.netrc`.
On Windows: `%HOME%\_netrc`, `%HOMEDRIVE%%HOMEPATH%\_netrc`, or `%USERPROFILE%\_netrc` (whichever is set first).

n = Netrc.read

Expand Down
5 changes: 4 additions & 1 deletion lib/netrc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class Netrc

def self.default_path
if WINDOWS && !CYGWIN
File.join(ENV['USERPROFILE'].gsub("\\","/"), "_netrc")
home = ENV['HOME']
home ||= ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
home ||= ENV['USERPROFILE']
File.join(home.gsub("\\","/"), "_netrc")
else
# In some cases, people run master process as "root" user, and run worker processes as "www" user.
# Fix "Permission denied" error in worker processes when $HOME is "/root".
Expand Down

0 comments on commit a05c2ef

Please sign in to comment.