question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variable expansion doesnt work as "pipenv requirements"

See original GitHub issue

Issue description

I am using private repo to install packages and it is refered in Pipfile.lock as like below

"sources": [
  "url":"https://$USER:$ACCESS_TOKEN@gitlab.com/private/repo"
]

Here, pipenv requirements > requirements.txt returns file using environment variables in unsupported format for pip install -r requirements.txt

Expected result(MODIFIED IN COMMENT)

# requirements.txt
-i https://expanded_username:expanded_token@gitlab.com/private/repo   
random_lib == 0.0.0  
...

pipenv lock --requirements > requirements.txt returned expected result(this command no longer available)

Actual result

# requirements.txt
-i https://$USER:$ACCESS_TOKEN@gitlab.com/private/repo   
random_lib == 0.0.0  
...

Only POSIX format is supported for pip install -r. https://pip.pypa.io/en/stable/reference/requirements-file-format/#using-environment-variables

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
matteiuscommented, Aug 26, 2022

As a workaround, couldn’t @RintaroMiyamoto specify the variables in the same way in the Pipfile?

"sources": [ "url":"https://${USER}:${ACCESS_TOKEN}@gitlab.com/private/repo" ]

1reaction
dqkqdcommented, Aug 18, 2022

The requirements file generated by the old command is definitely a bug, environment variables should not be expanded. But according to pipenv doc, pipenv supports for both $VARIABLE and %VARIABLE%, while pip doesn’t. That causes the issue. In order to work with pip, ${USER} should be used instead of $USER.

Read more comments on GitHub >

github_iconTop Results From Across the Web

variable expansion doesnt work inside Pipfile in order to ...
Issue description I am trying to install a dependency from a private repo in order to this I have the following line data...
Read more >
Advanced Usage of Pipenv - Read the Docs
Pipenv will expand environment variables (if defined) in your Pipfile. Quite useful if you need to authenticate to a private PyPI:.
Read more >
VS Code doesn't use pipenv .env file - Stack Overflow
1 on ubuntu 16.04 with a Python 3.7.3 pipenv virtual environment, I am trying to set environment variables in a .env file, but...
Read more >
pipenv Documentation - Read the Docs
Automatically install required Python version when pyenv is available. ... Pipenv will expand environment variables (if defined) in your Pipfile.
Read more >
python-dotenv - PyPI
By default, load_dotenv doesn't override existing environment variables. ... Python-dotenv can interpolate variables using POSIX variable expansion.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found