Skip to content

pyenv shell command runs twice #18669

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

Closed
FlorentLM opened this issue Mar 10, 2022 · 4 comments
Closed

pyenv shell command runs twice #18669

FlorentLM opened this issue Mar 10, 2022 · 4 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue

Comments

@FlorentLM
Copy link

FlorentLM commented Mar 10, 2022

Issue Type: Bug

Behaviour

Expected vs. Actual

When running a python line / block of code (with shift + enter), a new terminal opens and the command pyenv shell 3.10.2 is ran, but it appears to run twice, as the python interpreter receives it too:

pyenv shell 3.10.2
/Users/xxxx/.pyenv/versions/3.10.2/bin/python
❯ /Users/xxxx/.pyenv/versions/3.10.2/bin/python
Python 3.10.2 (main, Mar  9 2022, 00:46:05) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> pyenv shell 3.10.2
  File "<stdin>", line 1
    pyenv shell 3.10.2
          ^^^^^
SyntaxError: invalid syntax
>>> import os
>>> 

Steps to reproduce:

  1. Open any .py file, run any line with Shift + Enter, or with right click > 'Run selection/line in Python terminal'

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.2
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Pyenv
  • Value of the python.languageServer setting: Default
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "autopep8"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: false
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.2.1924087327
VS Code version: Code 1.65.1 (8908a9ca0f221f36507231afb39d2d8d1e182702, 2022-03-08T02:20:04.372Z)
OS version: Darwin arm64 21.2.0
Restricted Mode: No

System Info
Item Value
CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 8.00GB (0.10GB free)
Process Argv --crash-reporter-id 7944130e-e68a-4d6c-8d94-b8f3646178df
Screen Reader yes
VM 0%
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 10, 2022
@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments triage bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Mar 10, 2022
@karrtikr karrtikr added investigating We are looking into the cause of the issue and removed triage labels Mar 10, 2022
@minaelee
Copy link

minaelee commented Mar 16, 2022

Only after a recent update of both VS Code and pyenv, I also get pyenv shell running twice automatically whenever I open a VS Code integrated terminal. I've spoken with 2 other people today who are experiencing the exact same issue. Using macOS pyenv, not the forked pyenv-win.

Tested using both bash and zsh, same result. I normally use bash and do not have any pyenv config/initialization lines in my .zshrc so does not seem related to that.

Only happens in VS Code - using bash or zsh in macOS Terminal application does not result in the same issue.

image

@karrtikr
Copy link

karrtikr commented Apr 19, 2022

Thanks for opening the issue, because the shell is zsh this is a dup of microsoft/vscode#147016 in VSCode, please upvote the issue to raise priority.

@minaelee
Copy link

"because the shell is zsh"?
The screenshot above shows that it is happening in bash. Though as I said, it happens in both.
Look at the screenshot. The command prompt ends in $ for bash, not % for zsh. The text "The default interactive shell is now zsh." only appears in the terminal when the shell is NOT zsh, not when it IS zsh.

@karrtikr
Copy link

karrtikr commented Apr 21, 2022

The text led me to believe that it is zsh, but note it is not run twice, it only appears twice. The original issue here is that particularly for zsh, what happens is that the second command is executed before the first, which led to the error mentioned in the original bug.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug investigating We are looking into the cause of the issue
Projects
None yet
Development

No branches or pull requests

4 participants