mamba: mamba env create fails on Windows when using netrc

Calling mamba env create will fail on Windows if the .condarc file points to protected channels that have their auth info stored in a .netrc file.

This can be fixed by explicitly doing

set HOME=%USERPROFILE%

prior to running mamba env create, which leads me to believe that since mamba is calling directly into conda_env.cli.main it is bypassing some useful environmental management that conda does to help Windows operation suck less.

FWIW, mamba search and mamba install both work fine.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (5 by maintainers)

Most upvoted comments

@jonashaag It looks like conda’s session.py imports the get_netrc_auth function from requests.utils and uses that. The relevant part of that function (from requests code on github) is:

netrc_file = os.environ.get("NETRC")
    if netrc_file is not None:
        netrc_locations = (netrc_file,)
    else:
        netrc_locations = (f"~/{f}" for f in NETRC_FILES)

Additionally, in conda’s main.py, there is this code snippet here, which sets the netrc file location in the main info_dict:

    netrc_file = os.environ.get('NETRC')
    if not netrc_file:
        user_netrc = expanduser("~/.netrc")
        if isfile(user_netrc):
            netrc_file = user_netrc

In either case, the ~ construct is used to set the home directory, and that expands to USERPROFILE on Windows.