-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Cannot use environment variables defined in .env in pipenv run
and scripts in Pipfile
#4975
Comments
pipenv run
and scripts in Pipfilepipenv run
and scripts in Pipfile
@hmasdev It works if you do:
Not sure yet how to make the script section treat $FOO as a variable though, its clearly being treated as the string |
Related issue: #3901 |
@matteius |
As @matteius mentioned, I have tried Here I have two questions:
$ cat Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.10"
[scripts]
show-foo = "echo $FOO"
$ cat .env
FOO=SPAM
$ pipenv run echo $FOO
Loading .env environment variables...
$ NOTE: The setting is same as #4975 (comment) . |
@hmasdev Can you test with my proposed fixed in branch: |
@matteius $ pipenv run echo '$FOO'
Loading .env environment variables...
SPAM
$ pipenv run show-foo
Loading .env environment variables...
SPAM By the way, is the following result what you intended on $ pipenv run echo $FOO
Loading .env environment variables...
|
Not really, I think the master branch worked without the quotes for the run example ... that is kind of odd really. I'll have to think about it more. |
|
Thx! @matteius |
Issue description
I want to use environment variables defined in
.env
inpipenv run
and scripts inPipfile
.For example, when
FOO=SPAM
is in.env
andshow-foo = "echo $FOO"
is in Pipfile as a script, I want to getSPAM
by runningpipenv run echo '$FOO'
orpipenv run show-foo
.Expected result
Running
pipenv run echo '$FOO'
orpipenv run show-foo
returnsSPAM
with the following Pipfile and.env
:Actual result
Running
pipenv run echo '$FOO'
orpipenv run show-foo
behave as follows:$FOO
is not evaluated even ifFOO=SPAM
in.env
.Steps to replicate
create the following Pipfile
create
.env
run
pipenv run echo '$FOO'
orpipenv run show-foo
$ pipenv --support
Pipenv version:
'2022.1.8'
Pipenv location:
'/home/hmasu/.pyenv/versions/3.10.2/lib/python3.10/site-packages/pipenv'
Python location:
'/home/hmasu/.pyenv/versions/3.10.2/bin/python3.10'
Python installations found:
3.10.2
:/home/hmasu/.pyenv/versions/3.10.2/bin/python3
3.10.2
:/home/hmasu/.pyenv/versions/3.10.2/bin/python
3.10.2
:/home/hmasu/.pyenv/versions/3.10.2/bin/python3
3.9.8
:/home/hmasu/.pyenv/versions/3.9.8/bin/python3.9
3.8.5
:/usr/bin/python3.8
3.8.5
:/usr/bin/python3
3.8.5
:/bin/python3.8
3.8.5
:/bin/python3
3.7.12
:/home/hmasu/.pyenv/versions/3.7.12/bin/python3.7
2.7.18
:/usr/bin/python2
2.7.18
:/usr/bin/python2.7
2.7.18
:/bin/python2
2.7.18
:/bin/python2.7
PEP 508 Information:
System environment variables:
SHELL
PYENV_HOOK_PATH
PYENV_SHELL
WSL_DISTRO_NAME
PYENV_VERSION
NAME
PWD
LOGNAME
HOME
LANG
WSL_INTEROP
PYENV_DIR
TERM
USER
DISPLAY
SHLVL
PYENV_ROOT
WSLENV
XDG_DATA_DIRS
PATH
HOSTTYPE
PIP_SHIMS_BASE_MODULE
PIP_DISABLE_PIP_VERSION_CHECK
PYTHONDONTWRITEBYTECODE
PIP_PYTHON_PATH
PYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
Debug–specific environment variables:
PATH
:/home/hmasu/.pyenv/versions/3.10.2/bin:/home/hmasu/.pyenv/libexec:/home/hmasu/.pyenv/plugins/python-build/bin:/home/hmasu/.pyenv/shims:/home/hmasu/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.Ubuntu20.04onWindows_2004.2022.8.0_x64__79rhkp1fndgsc:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/libnvvp:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0:/mnt/c/windows/System32/OpenSSH:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files/dotnet:/mnt/c/Program Files/NVIDIA Corporation/Nsight Compute 2019.4.0:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/mnt/c/Program Files/Azure Data Studio/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/ProgramData/DockerDesktop/version-bin:/mnt/c/Users/hmasu/.windows-build-tools/python27:/mnt/c/Users/hmasu/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/hmasu/bat:/mnt/c/tools/cuda/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/extras/CUPTI/libx64:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.0/include:/mnt/c/Users/hmasu/AppData/Roaming/npm:/mnt/c/Users/hmasu/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/LLVM/bin:/mnt/c/Users/hmasu/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/hmasu/AppData/Local/Programs/Julia-1.6.0/bin:/snap/bin
SHELL
:/bin/bash
LANG
:C.UTF-8
PWD
:/mnt/d/workspace/pipenv-.env-exp
Contents of
Pipfile
('/mnt/d/workspace/pipenv-.env-exp/Pipfile'):Contents of
Pipfile.lock
('/mnt/d/workspace/pipenv-.env-exp/Pipfile.lock'):The text was updated successfully, but these errors were encountered: