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

Revert "Make http_archive honor $HOME/.netrc" #9341

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions src/test/shell/bazel/skylark_repository_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1852,41 +1852,4 @@ EOF
|| fail "Expected success despite needing a file behind basic auth"
}

function test_implicit_netrc() {
mkdir x
echo 'exports_files(["file.txt"])' > x/BUILD
echo 'Hello World' > x/file.txt
tar cvf x.tar x
sha256=$(sha256sum x.tar | head -c 64)
serve_file_auth x.tar

export HOME=`pwd`
cat > .netrc <<'EOF'
machine 127.0.0.1
login foo
password bar
EOF

mkdir main
cd main
cat > WORKSPACE <<EOF
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name="ext",
url = "http://127.0.0.1:$nc_port/x.tar",
sha256="$sha256",
)
EOF
cat > BUILD <<'EOF'
genrule(
name = "it",
srcs = ["@ext//x:file.txt"],
outs = ["it.txt"],
cmd = "cp $< $@",
)
EOF
bazel build //:it \
|| fail "Expected success despite needing a file behind basic auth"
}

run_suite "local repository tests"
10 changes: 1 addition & 9 deletions tools/build_defs/repo/http.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ def _get_auth(ctx, urls):
netrc = read_netrc(ctx, ctx.attr.netrc)
return use_netrc(netrc, urls)

if "HOME" in ctx.os.environ:
if not ctx.os.name.startswith("windows"):
netrcfile = "%s/.netrc" % (ctx.os.environ["HOME"],)
if ctx.execute(["test", "-f", netrcfile]).return_code == 0:
netrc = read_netrc(ctx, netrcfile)
return use_netrc(netrc, urls)

# TODO: Search at a similarly canonical place for Windows as well

# TODO: use ~/.netrc instead, if it exists and is readable
return {}

def _http_archive_impl(ctx):
Expand Down