pipenv doesn't honor NETRC environment variable
See original GitHub issueIssue description
pipenv does not honor the NETRC
environment variable.
… a location outside of the home directory can be set using the environment variable
NETRC
…
Expected result
pipenv should leverage the path specified in the NETRC
environment variable; requests library does this already:
- Original PR to add: https://github.com/psf/requests/pull/5643
- Relevant current (requests) source: here
Actual result
pipenv does not use the set NETRC
variable, defaulting to only ~/.netrc
and ~/_netrc
paths. If using a private source (e.g Artifactory) as a url
in [[source]]
, this results in a [pipenv.exceptions.ResolutionFailure]
:
...
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: Could not find a version that matches asyncssh (from -r .... (line 3))
No versions found
Was <private artifactory URL> reachable?
Copying the .netrc
file from the custom dir to either ~/.netrc
and/or ~/_netrc
then successfully works with no other modifications to the Pipfile
file (and it resolves with public sources fine as well, so is not an issue with the packages/dependencies or something like that)
Steps to replicate
Pipfile:
[[source]]
url = "<some private pypi repository URL>"
verify_ssl = true
name = "Private PyPi"
[packages]
requests = "*"
asyncssh = "*"
[dev-packages]
[requires]
python_version = "3.10"
Create a .netrc
in some directory path thats not ~/.netrc
or ~/_netrc
(and make sure that there are no files there currently, otherwise, temporarily move them to something like ~/.netrc.temp_backup
.
machine <private repo base URL>
login <user>
password <pw | key>
Then set NETRC
to the path to that file:
export NETRC=/some/path/to/that/.netrc
Then, try:
pipenv install
pipenv --version
pipenv, version 2021.5.29
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top GitHub Comments
Hey 👋 , sorry for the delay, but it looks good now!
Checking what I have currently (trying this just now on macOS, fwiw):
With a test
Pipfile
like so:and a
~/.netrc
ofA
pipenv install
works properly, and thePipfile.lock
shows the expected source:Doing a clean re-install with a custom
NETRC
envar also works:(i.e it also successfully installs and shows the expected source in the lock file)
@bigpick any updates?