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

Formatting issue for venv activations on the terminal #24533

Open
songyang-dev opened this issue Dec 3, 2024 · 3 comments
Open

Formatting issue for venv activations on the terminal #24533

songyang-dev opened this issue Dec 3, 2024 · 3 comments
Assignees
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@songyang-dev
Copy link

Type: Bug

Behaviour

The (.venv) marker in the terminal is not formatted properly. Right now, it is just plain text .venv and immediately with no spacing follows the user@machine. It used to be (.venv) user@machine.

Image

Steps to reproduce:

  1. Create a venv folder.
  2. Close and reopen VS Code.

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-12-03 13:37:16.239 [info] Experiment 'pythonRecommendTensorboardExt' is active
2024-12-03 13:37:16.239 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2024-12-03 13:37:16.239 [info] Experiment 'pythonTestAdapter' is active
2024-12-03 13:37:16.239 [info] Native locator: Refresh started
2024-12-03 13:37:16.239 [info] > pyenv which python
2024-12-03 13:37:16.239 [info] cwd: .
2024-12-03 13:37:16.245 [info] > conda info --json
2024-12-03 13:37:16.259 [info] Python interpreter path: ./.venv/bin/python
2024-12-03 13:37:16.276 [info] Native locator: Refresh finished in 490 ms
2024-12-03 13:37:16.284 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py
2024-12-03 13:37:16.284 [info] shell: zsh
2024-12-03 13:37:16.324 [info] > /Library/Developer/CommandLineTools/usr/bin/python3 ~/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariables.py
2024-12-03 13:37:16.324 [info] shell: zsh
2024-12-03 13:37:16.354 [info] Prepending environment variable PATH in collection with /Users/songyang/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/deactivate/zsh:/Users/songyang/Documents/Outlier/.venv/bin: {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-03 13:37:16.354 [info] Setting environment variable VIRTUAL_ENV in collection to /Users/songyang/Documents/Outlier/.venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-03 13:37:16.354 [info] Setting environment variable VIRTUAL_ENV_PROMPT in collection to .venv {"applyAtShellIntegration":true,"applyAtProcessCreation":true}
2024-12-03 13:37:16.354 [info] Prepending environment variable PS1 in collection with .venv {"applyAtShellIntegration":true,"applyAtProcessCreation":false}
2024-12-03 13:37:16.354 [info] Send text to terminal: /Library/Developer/CommandLineTools/usr/bin/python3 /Users/songyang/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/printEnvVariablesToFile.py /Users/songyang/.vscode/extensions/ms-python.python-2024.20.0-darwin-arm64/python_files/deactivate/zsh/envVars.txt
2024-12-03 13:37:26.369 [info] Starting Pylance language server.

Extension version: 2024.20.0
VS Code version: Code 1.95.3 (Universal) (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z)
OS version: Darwin arm64 24.1.0
Modes:

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


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
Bash IDE mads-hartmann.bash-ide-vscode 1.43.0
Bun for Visual Studio Code oven.bun-vscode 0.0.23
C/C++ ms-vscode.cpptools 1.22.11
CodeLLDB vadimcn.vscode-lldb 1.11.1
Dart Dart-Code.dart-code 3.102.0
Dev Containers ms-vscode-remote.remote-containers 0.388.0
Edit csv janisdd.vscode-edit-csv 0.10.0
ESLint dbaeumer.vscode-eslint 3.0.10
Even Better TOML tamasfe.even-better-toml 0.19.2
Flutter Dart-Code.flutter 3.102.0
Flutter Riverpod Snippets robert-brunhage.flutter-riverpod-snippets 1.2.2
GitHub Copilot GitHub.copilot 1.246.0
GitHub Copilot Chat GitHub.copilot-chat 0.22.4
Go golang.go 0.42.1
HTML CSS Support ecmel.vscode-html-css 2.0.11
JavaScript (ES6) code snippets xabikos.JavaScriptSnippets 1.8.0
JavaScript Debugger ms-vscode.js-debug 1.95.3
JavaScript Debugger Companion Extension ms-vscode.js-debug-companion 1.1.3
Jupyter ms-toolsai.jupyter 2024.10.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Keymap ms-toolsai.jupyter-keymap 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.21
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
Live Server ritwickdey.LiveServer 5.7.9
npm Intellisense christian-kohler.npm-intellisense 1.4.5
Prettier - Code formatter esbenp.prettier-vscode 11.0.0
Pylance ms-python.vscode-pylance 2024.11.3
Python ms-python.python 2024.20.0
Python Debugger ms-python.debugpy 2024.12.0
Rainbow CSV mechatroner.rainbow-csv 3.13.0
Remote - SSH ms-vscode-remote.remote-ssh 0.115.1
Remote - SSH: Editing Configuration Files ms-vscode-remote.remote-ssh-edit 0.87.0
Remote - Tunnels ms-vscode.remote-server 1.5.2
Remote Development ms-vscode-remote.vscode-remote-extensionpack 0.26.0
Remote Explorer ms-vscode.remote-explorer 0.4.3
rust-analyzer rust-lang.rust-analyzer 0.3.2204
Svg Preview SimonSiefke.svg-preview 2.8.3
Swift sswg.swift-lang 1.11.3
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.10
vscode-icons vscode-icons-team.vscode-icons 12.9.0
Vue - Official Vue.volar 2.1.10
WSL ms-vscode-remote.remote-wsl 0.88.5
System Info
Item Value
CPUs Apple M3 (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 2
Memory (System) 8.00GB (0.09GB free)
Process Argv --crash-reporter-id 0d9ea874-4610-42fd-bd74-f3c5a189aa3b
Screen Reader yes
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythonnoceb:30805159
asynctok:30898717
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupyter:31046869
newcmakeconfigv2:31071590
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Dec 3, 2024
@songyang-dev songyang-dev changed the title venv activation console notice formatting Formatting issue for venv activations on the terminal Dec 3, 2024
@anthonykim1
Copy link

Hi @songyang-dev Thanks for filing this issue.
Can you please add
"python.experiments.optOutFrom": ["pythonTerminalEnvVarActivation"], to your settings.json and see if the issue persists?
Thanks.

@anthonykim1 anthonykim1 added area-terminal bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Dec 4, 2024
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Dec 4, 2024
@songyang-dev
Copy link
Author

Image
The issue disappeared as you can see from the screenshot. But there is no more venv active.

@maxdymond
Copy link

maxdymond commented Dec 12, 2024

I noticed this as well; one workaround is to specify the prompt when creating the venv:

python3.13 -m venv --prompt "(.venv) " .venv

Without it I was getting:

- `VIRTUAL_ENV_PROMPT=.venv`
- `PS1=.venv${env:PS1}`

in the Environment changes tab for a terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants