Merge pull request #4022 from stefansundin/disable-curlrc
Tell curl to not use .curlrc
This commit is contained in:
commit
99b89e4866
@ -47,7 +47,15 @@ fetch() {
|
||||
local sha
|
||||
local temporary_path
|
||||
|
||||
curl_args=(
|
||||
curl_args=()
|
||||
|
||||
# do not load .curlrc unless requested (must be the first argument)
|
||||
if [[ -n "$HOMEBREW_CURLRC" ]]
|
||||
then
|
||||
curl_args[${#curl_args[*]}]="-q"
|
||||
fi
|
||||
|
||||
curl_args+=(
|
||||
--fail
|
||||
--remote-time
|
||||
--location
|
||||
|
||||
@ -480,21 +480,6 @@ module Homebrew
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_user_curlrc
|
||||
curlrc_found = %w[CURL_HOME HOME].any? do |var|
|
||||
ENV[var] && File.exist?("#{ENV[var]}/.curlrc")
|
||||
end
|
||||
return unless curlrc_found
|
||||
|
||||
<<~EOS
|
||||
You have a curlrc file
|
||||
If you have trouble downloading packages with Homebrew, then maybe this
|
||||
is the problem? If the following command doesn't work, then try removing
|
||||
your curlrc:
|
||||
curl #{Formatter.url("https://github.com")}
|
||||
EOS
|
||||
end
|
||||
|
||||
def check_for_gettext
|
||||
find_relative_paths("lib/libgettextlib.dylib",
|
||||
"lib/libintl.dylib",
|
||||
|
||||
@ -138,6 +138,10 @@ Note that environment variables must have a value set to be detected. For exampl
|
||||
|
||||
*Default:* `~/Library/Caches/Homebrew`.
|
||||
|
||||
* `HOMEBREW_CURLRC`:
|
||||
If set, Homebrew will not pass `-q` when invoking `curl`(1) (which disables
|
||||
the use of `curlrc`).
|
||||
|
||||
* `HOMEBREW_CURL_VERBOSE`:
|
||||
If set, Homebrew will pass `--verbose` when invoking `curl`(1).
|
||||
|
||||
|
||||
@ -131,15 +131,6 @@ describe Homebrew::Diagnostic::Checks do
|
||||
end
|
||||
end
|
||||
|
||||
specify "#check_user_curlrc" do
|
||||
mktmpdir do |path|
|
||||
FileUtils.touch "#{path}/.curlrc"
|
||||
ENV["CURL_HOME"] = path
|
||||
|
||||
expect(subject.check_user_curlrc).to match("You have a curlrc file")
|
||||
end
|
||||
end
|
||||
|
||||
specify "#check_for_config_scripts" do
|
||||
mktmpdir do |path|
|
||||
file = "#{path}/foo-config"
|
||||
|
||||
15
Library/Homebrew/test/utils/curl_spec.rb
Normal file
15
Library/Homebrew/test/utils/curl_spec.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require "utils/curl"
|
||||
|
||||
describe "curl" do
|
||||
describe "curl_args" do
|
||||
it "returns -q as the first argument when HOMEBREW_CURLRC is set" do
|
||||
ENV["HOMEBREW_CURLRC"] = "1"
|
||||
# -q must be the first argument according to "man curl"
|
||||
expect(curl_args("foo")[1]).to eq("-q")
|
||||
end
|
||||
|
||||
it "doesn't return -q as the first argument when HOMEBREW_CURLRC is not set" do
|
||||
expect(curl_args("foo")[1]).to_not eq("-q")
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -11,10 +11,14 @@ def curl_executable
|
||||
end
|
||||
|
||||
def curl_args(*extra_args, show_output: false, user_agent: :default)
|
||||
args = [
|
||||
curl_executable.to_s,
|
||||
"--show-error",
|
||||
]
|
||||
args = [curl_executable.to_s]
|
||||
|
||||
# do not load .curlrc unless requested (must be the first argument)
|
||||
if ENV["HOMEBREW_CURLRC"]
|
||||
args << "-q"
|
||||
end
|
||||
|
||||
args << "--show-error"
|
||||
|
||||
args << "--user-agent" << case user_agent
|
||||
when :browser, :fake
|
||||
|
||||
@ -1110,6 +1110,10 @@ Note that environment variables must have a value set to be detected. For exampl
|
||||
|
||||
*Default:* `~/Library/Caches/Homebrew`.
|
||||
|
||||
* `HOMEBREW_CURLRC`:
|
||||
If set, Homebrew will not pass `-q` when invoking `curl`(1) (which disables
|
||||
the use of `curlrc`).
|
||||
|
||||
* `HOMEBREW_CURL_VERBOSE`:
|
||||
If set, Homebrew will pass `--verbose` when invoking `curl`(1).
|
||||
|
||||
|
||||
@ -1129,6 +1129,10 @@ If set, instructs Homebrew to use the given directory as the download cache\.
|
||||
\fIDefault:\fR \fB~/Library/Caches/Homebrew\fR\.
|
||||
.
|
||||
.TP
|
||||
\fBHOMEBREW_CURLRC\fR
|
||||
If set, Homebrew will not pass \fB\-q\fR when invoking \fBcurl\fR(1) (which disables the use of \fBcurlrc\fR)\.
|
||||
.
|
||||
.TP
|
||||
\fBHOMEBREW_CURL_VERBOSE\fR
|
||||
If set, Homebrew will pass \fB\-\-verbose\fR when invoking \fBcurl\fR(1)\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user