Skip to content
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

Running pipenv shell in oh-my-posh doesn't set VIRTUAL_ENV #6226

Open
MrPaulAR opened this issue Aug 29, 2024 · 4 comments
Open

Running pipenv shell in oh-my-posh doesn't set VIRTUAL_ENV #6226

MrPaulAR opened this issue Aug 29, 2024 · 4 comments
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged.

Comments

@MrPaulAR
Copy link

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv.

Check the diagnose documentation for common issues before posting! We may close your issue if it is very similar to one of them. Please be considerate, or be on your way.

Make sure to mention your debugging experience if the documented solution failed.

Issue description

On a zsh shell on Arch, Ubuntu, & WSL when I execute pipenv shell the env variable VIRTUAL_ENV is not being set. If I create a traditional venv and activate it then the variable is being set.

Versions:

  • zsh: 5.8.1
  • python: 3.12.5
  • pipenv: 2024.0.1

Expected result

After executing pipenv shell typing echo $VIRTUAL_ENV should show the name of the virtual environment.

Actual result

When possible, provide the verbose output (--verbose), especially for locking and dependencies resolving issues.

$  pipenv shell --verbose
Launching subshell in virtual environment...
 . /home/tmpuser/.local/share/virtualenvs/tmp-g6-Tn6kM/bin/activate
--verbose
$  echo $VIRTUAL_ENV       

$  source venv/bin/activate
$  echo $VIRTUAL_ENV
/home/tempuser/tmp/venv

Steps to replicate

  • Create a blank user account
  • Install asdf-vm and python
    • asdf plugin-add python
    • asdf install python latest
    • asdf global python latest
    • pip install pipenv
  • Install oh-my-posh
  • Below is the contents of my .zshrc file
  • mkdir tmp; cd tmp
  • Create pipenv & venv
    • pipenv install
    • python -m venv venv

Inside this temp dir I can activate either of the virutal enviroments but only the venv one sets the VIRTUAL_ENV env variable.


$ pipenv --support

Pipenv version: '2024.0.1'

Pipenv location: '/home/tmpuser/.asdf/installs/python/3.12.5/lib/python3.12/site-packages/pipenv'

Python location: '/home/tmpuser/.asdf/installs/python/3.12.5/bin/python3.12'

OS Name: 'posix'

User pip version: '24.0'

user Python installations found:

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.12.5',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '6.8.12-1-pve',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP PREEMPT_DYNAMIC PMX 6.8.12-1 (2024-08-05T16:17Z)',
 'python_full_version': '3.12.5',
 'python_version': '3.12',
 'sys_platform': 'linux'}

System environment variables:

  • PATH
  • SHELL
  • ZLE_RPROMPT_INDENT
  • POSH_PID
  • SSH_AUTH_SOCK
  • PWD
  • LOGNAME
  • XDG_SESSION_TYPE
  • ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
  • MOTD_SHOWN
  • HOME
  • LANG
  • POSH_SHELL_VERSION
  • OSTYPE
  • CONDA_PROMPT_MODIFIER
  • ASDF_DATA_DIR
  • SSH_CONNECTION
  • XDG_SESSION_CLASS
  • TERM
  • POSH_PROMPT_COUNT
  • ASDF_DIR
  • USER
  • SHLVL
  • XDG_SESSION_ID
  • POSH_THEME
  • XDG_RUNTIME_DIR
  • SSH_CLIENT
  • DEBUGINFOD_URLS
  • ASDF_CONFIG_FILE
  • DBUS_SESSION_BUS_ADDRESS
  • MAIL
  • SSH_TTY
  • POWERLINE_COMMAND
  • OLDPWD
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH
  • PIPENV_ACTIVE
  • _
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

  • PIPENV_ACTIVE: 1

Debug–specific environment variables:

  • PATH: /home/tmpuser/.asdf/installs/python/3.12.5/bin:/home/tmpuser/.asdf/plugins/python/shims:/home/tmpuser/.asdf/installs/python/3.12.5/bin:/home/tmpuser/.asdf/shims:/home/tmpuser/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/tmpuser/.local/bin:/home/tmpuser/.local/bin
  • SHELL: /usr/bin/zsh
  • LANG: C.UTF-8
  • PWD: /home/tmpuser/temprepo

Contents of Pipfile ('/home/tmpuser/temprepo/Pipfile'):

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.12"

I'm not sure if this is oh-my-posh squashing the env var or pipenv not setting it, if nothing else hoping for some direction.

@CVirus
Copy link

CVirus commented Sep 5, 2024

Facing exactly the same issue here.

@MrPaulAR
Copy link
Author

MrPaulAR commented Sep 6, 2024

There is a discussion in JanDeDobbeleer/oh-my-posh#5573 where @CVirus identified that if you create a shell with pipenv shell --fancy things work as expected. Not sure if this is a pipenv or oh-my-posh issue so not closing this as of yet.

@matteius
Copy link
Member

matteius commented Sep 6, 2024

Is this something that can be worked into: #6230

@oz123
Copy link
Contributor

oz123 commented Sep 10, 2024

I don't think that a fix for the issue should be incorporated into the PR you mentioned, as it is a local fix for a thing which already worked. I believe the fancy solution is OK. If needed, I am willing to open another PR to fix this issue, as it is easy for me to test.

@matteius matteius added the Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged. label Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contributor Candidate The issue has been identified/triaged and contributions are welcomed/encouraged.
Projects
None yet
Development

No branches or pull requests

4 participants