VSCode cannot enable python environment when OMP is used #7217
Unanswered
MariusRoger
asked this question in
Troubleshoot
Replies: 2 comments 2 replies
-
|
@MariusRoger what does your config look like? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hi, my full OMP config is the following : console_title_template = '{{ .Shell }} in {{ .Folder }}'
version = 4
final_space = true
enable_cursor_positioning = true
[upgrade]
source = 'cdn'
interval = '72h'
auto = true
notice = true
[[blocks]]
type = 'prompt'
alignment = 'left'
newline = true
trailing_diamond = ""
[[blocks.segments]]
type = 'path'
template = " {{.Path}}"
style = 'diamond'
leading_diamond = ""
trailing_diamond = ""
background = 'cyan'
foreground = "black"
[blocks.segments.options]
style = 'agnoster_short'
max_depth = 2
[[blocks.segments]]
type = 'git'
style = 'diamond'
foreground = "#f34f29"
background = "transparent"
template = " {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if or (.Staging.Changed) (.Working.Changed) }} *{{ end }}"
[blocks.segments.options]
branch_icon = ""
branch_identical_icon = ""
branch_gone_icon = ""
commit_icon = ""
rebase_icon = ""
no_commits_icon = ""
fetch_status = true
[[blocks]]
type = "prompt"
alignment = "right"
[[blocks.segments]]
type = "executiontime"
style = "plain"
foreground = "darkGray"
template = " {{ if gt .Code 0 }}<red>{{ end }} {{ .FormattedMs }}</>"
[[blocks.segments]]
type = "python"
style = "plain"
foreground = "blue"
template = " {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }}"
[[blocks]]
type = 'prompt'
alignment = "left"
newline = true
[[blocks.segments]]
type = "text"
style = "plain"
template = ""
[transient_prompt]
foreground = "darkGray"
template = "{{if .Segments.Executiontime.FormattedMs }}{{ if gt .Code 0 }}<red>{{ end }} {{ .Segments.Executiontime.FormattedMs }}</>\n{{end}}<cyan>{{ .Segments.Path.Path }}</>{{ if .Segments.Git.HEAD }} {{ .Segments.Git.HEAD }}{{end}} "
[[tooltips]]
type = "git"
tips = [ "git", "g" ]
style = "diamond"
foreground = "#193549"
background = "#fffb38"
leading_diamond = ""
trailing_diamond = ""
[tooltips.options]
fetch_status = true
fetch_upstream_icon = true
branch_icon = ""
branch_identical_icon = ""
branch_gone_icon = ""However, this behavior also appears with the more minimal config I shared above. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am running into the issue that VS Code (or more specifically the Python extension) cannot activate python environments when OMP is active in the terminal.
I am not sure if this is an OMP, VS Code, or vscode-python issue, thus the discussion here : feel free to redirect me if this would be more relevant elsewhere.
Description of my issue
I am using zsh on EndeavourOS linux, with oh-my-posh in version
29.0.2.This issue only appears when
eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/perso.toml)"is not commented out in my.zshrc.This happens with a very minimal config such as
I check it by running

which pythonto be sure it is not a segment display issue.If OMP is active, and I write
source /home/marius/myproject/env/bin/activatemyself, everything works : either inside VS Code or in another terminal emulator.VS Code settings are very minimal and should not impact this
{ "chat.disableAIFeatures": true, "editor.fontFamily": "'JetBrainsMono Nerd Font', 'Droid Sans Mono', 'monospace', monospace", "workbench.activityBar.location": "top", "terminal.integrated.fontFamily": "JetBrainsMono Nerd Font", "terminal.integrated.fontSize": 14.5, "terminal.integrated.fontWeight": "550", "[python]": { "editor.formatOnSave": true, "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { "source.organizeImports": "explicit" } }, "workbench.startupEditor": "none" }What I tried or found
This happens independently from the "shell integration" VS Code settings (terminal.integrated or python.terminal)
From what I understand (with the help of an LLM, so this may be incorrect), the Python extension sends
terminal startup with OMP
terminal startup without OMP
source /home/marius/myproject/env/bin/activateas full text to the terminal (I see it written just above my customized prompt), and the use of ZSH Line Editing in OMP locks this input channel. When commenting the OMP line, the env activation is written before the default zsh prompt and then written again/properly executed.I see here Typing messes up terminal/venv activation microsoft/vscode-python#24589 (comment) that there is a delay that happens before the command is sent. Could I delay the loading of OMP until after this command is executed ? Or will it not get executed at all until all of
.zshrcis sourced ?I am aware that there is the Python Environments module that is being rolled out and provides a way to activate environment before even loading the terminal, but I am facing Refreshing virtual environments keeps on spinning due to missing pyenv microsoft/vscode-python-environments#1059 so that is not an option for me until it is resolved.
Alternatively, is there a (hidden) option in oh-my-posh CLI to generate a prompt that does not rely on ZLE ? I could not find one using the OMP CLI help. I get transient prompt and tooltips would probably be unavailable, but if that is what it takes for this setup to work I can bear it within an IDE. I would then detect in
.zshrcif the terminal is launched by vscode (through theTERM_PROGRAM=vscodeenvironment variable) and switch conditionally.Would OMP debug be useful ? I could not find a way to have
oh-my-posh debug --config $HOME/.config/ohmyposh/simple.tomltake into account the fact that I want to use zsh, as it seems addinginit zshafterdebugdoes not do much.If there is no possible solution, then I will just activate either activate the environment or OMP by hand depending on which one annoys me the least, but I would really appreciate being able to use the existing automation.
Any help is appreciated anyway !
Beta Was this translation helpful? Give feedback.
All reactions