Skip to content

Commit

Permalink
respect user's curlrc file (Homebrew#516)
Browse files Browse the repository at this point in the history
Users may have ~/.curlrc file to include options like proxies.
However, since we overwrite HOME environment variable during the build
and test, curl won't be able to find it.

This commit solves this issue by using CURL_HOME environment variable,
which will be pointed to the original HOME path.

From `curl(1)`:
> 1) curl tries to find the "home dir": It first  checks  for  the
     CURL_HOME and then the HOME environment variables. Failing that,
     it uses getpwuid() on Unix-like systems (which returns the  home
     dir  given the current user in your system). On Windows, it then
     checks for the APPDATA variable, or as a last resort the '%USER-
     PROFILE%\Application Data'.
  • Loading branch information
xu-cheng committed Jul 15, 2016
1 parent 2b078be commit de366f7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,8 @@ def verify_download_integrity(fn)
# @private
def run_test
old_home = ENV["HOME"]
old_curl_home = ENV["CURL_HOME"]
ENV["CURL_HOME"] = old_curl_home || old_home
build, self.build = self.build, Tab.for_formula(self)
mktemp("#{name}-test") do |staging|
staging.retain! if ARGV.keep_tmp?
Expand All @@ -1341,6 +1343,7 @@ def run_test
@testpath = nil
self.build = build
ENV["HOME"] = old_home
ENV["CURL_HOME"] = old_curl_home
end

# @private
Expand Down Expand Up @@ -1555,13 +1558,16 @@ def stage
mkdir_p env_home

old_home, ENV["HOME"] = ENV["HOME"], env_home
old_curl_home = ENV["CURL_HOME"]
ENV["CURL_HOME"] = old_curl_home || old_home
setup_home env_home

begin
yield staging
ensure
@buildpath = nil
ENV["HOME"] = old_home
ENV["CURL_HOME"] = old_curl_home
end
end
end
Expand Down

0 comments on commit de366f7

Please sign in to comment.