Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell curl to not use .curlrc #4022

Merged
merged 3 commits into from Apr 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion Library/Homebrew/cmd/vendor-install.sh
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions Library/Homebrew/diagnostic.rb
Expand Up @@ -480,21 +480,6 @@ def check_user_path_3
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",
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/manpages/brew.1.md.erb
Expand Up @@ -136,6 +136,10 @@ can take several different forms:

*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).

Expand Down
9 changes: 0 additions & 9 deletions Library/Homebrew/test/diagnostic_spec.rb
Expand Up @@ -131,15 +131,6 @@
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"
Expand Down
15 changes: 15 additions & 0 deletions Library/Homebrew/test/utils/curl_spec.rb
@@ -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
12 changes: 8 additions & 4 deletions Library/Homebrew/utils/curl.rb
Expand Up @@ -12,10 +12,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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this backwards? Now we will still load curlrc by default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stefansundin It is indeed, I'm a moron! Fixed in #4045, thanks for noticing!

args << "-q"
end

args << "--show-error"

args << "--user-agent" << case user_agent
when :browser, :fake
Expand Down
4 changes: 4 additions & 0 deletions docs/Manpage.md
Expand Up @@ -1110,6 +1110,10 @@ can take several different forms:

*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).

Expand Down
2 changes: 1 addition & 1 deletion manpages/brew-cask.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW\-CASK" "1" "March 2018" "Homebrew" "brew-cask"
.TH "BREW\-CASK" "1" "April 2018" "Homebrew" "brew-cask"
.
.SH "NAME"
\fBbrew\-cask\fR \- a friendly binary installer for macOS
Expand Down
6 changes: 5 additions & 1 deletion manpages/brew.1
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "BREW" "1" "March 2018" "Homebrew" "brew"
.TH "BREW" "1" "April 2018" "Homebrew" "brew"
.
.SH "NAME"
\fBbrew\fR \- The missing package manager for macOS
Expand Down Expand Up @@ -1128,6 +1128,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)\.
.
Expand Down