threads / discuss / 62587

Support of NETRC environment variable

Subject: Support of NETRC environment variable

## tl;dr

2 messages between Dec 2, 2024 and Dec 2, 2024.

replies: 1people: 2as markdown or json

Rémi Debette· Dec 2, 2024, 17:36 UTC · lore
Hi,

This email follows discussions on this issue in the uv project: https://github.com/astral-sh/uv/issues/9576

The uv project supports setting an environment variable called NETRC that allows setting a path to a .netrc file if this one is not in the expected home path ~/.netrc Their documentation describes it here: https://docs.astral.sh/uv/configuration/environment/#netrc

git supports authenticating through the .netrc home file, but it seems it does not recognize this NETRC environment variable. Would there be an alternative way to set an alternate path?

Thank you Rémi DEBETTE

Jeff King· Dec 2, 2024, 21:11 UTC · re: Rémi Debette · lore

Re: Support of NETRC environment variable

On Mon, Dec 02, 2024 at 06:36:34PM +0100, Rémi Debette wrote:
Show 12 quoted lines
> This email follows discussions on this issue in the uv project:
> https://github.com/astral-sh/uv/issues/9576
> 
> The uv project supports setting an environment variable called NETRC
> that allows setting a path to a .netrc file if this one is not in the
> expected home path ~/.netrc
> Their documentation describes it here:
> https://docs.astral.sh/uv/configuration/environment/#netrc
> 
> git supports authenticating through the .netrc home file, but it seems
> it does not recognize this NETRC environment variable.
> Would there be an alternative way to set an alternate path?

No, there isn't. Git does not really support netrc itself[1]. But we do rely on libcurl for making http requests, and it handles it internally. The only explicit thing Git does is turn on the libcurl option that allows the use of netrc.

It looks like curl also has a CURLOPT_NETRC_FILE option. So I think there _could_ be a Git patch that takes the value from $NETRC and passes it there. But if this is a standard-ish interface, I wonder if it would make more sense to lobby curl folks to support $NETRC automatically.

-Peff
[1] There's also a netrc credential helper in contrib/, but that may
    defeat the purpose if you're looking for something people can just
    use out of the box. They'd need to build and install the helper, and
    then configure it.

← back to recent threads