You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Powershell fails every prompt in pixi shell after cancelling (ctrl+c) #514
changed the title [-]Powershell fails every command in pixi shell after cancelling (ctrl+c) one[/-][+]Powershell fails every command in pixi shell after cancelling (ctrl+c)[/+]on Nov 28, 2023
changed the title [-]Powershell fails every command in pixi shell after cancelling (ctrl+c)[/-][+]Powershell fails every prompt in pixi shell after cancelling (ctrl+c)[/+]on Nov 28, 2023
I am experiencing this also on Command Prompt. Interestingly, it seems that the pixi environment is actually active when the prompt does not have the (envname) modifier, while the (envname) modifier is present, the environment is not active, see :
This is particularly annoying as it appears to happen when you use Ctrl+C to close a running program, like:
pixi shell
runsomeprogram :: You press Ctrl+C to exit:: now the shell is corrupted
I guess most users on Windows are probably using pixi run , so they are not encountering this. I think I will eventually try to tackle this problem, as it is quite annoying. Anyone has some pointers to relevant part of the codes it may be worth start looking into?
I have the same issue.
When the terminal is corrupted, it behaves as if it is running both the pixi-shell and the powershell on the foreground.
The input from the keyboard is sent to the pixi-shell and powershell on alternating keystrokes.
This can be demonstrated by getting the process ID of powershell and the pixi-shell, then corrupting the pixi-shell and checking the pids of both processes.
Steps:
Start a powershell terminal
Get the powershell pid: echo $pid
Start the pixi shell: pixi shell
Get the pixi-shell pid: echo $pid
Corrupt the terminal as the OP suggested: sleep(1000)Enter and within 1 seconds Ctrl + C
type echo $pid but type every keystroke twice
Observe: Every time a key is pressed the cursor alternates between PS> and (pixi-env)PS>
Press Enter twice (one for each process)
Observe: One PID is the powershell, one is the pixi-shell
Are there any Ctrl + C hooks that could cause this behavior in the pixi-shell?
Reacted by Silvio Traversaro, matt wilkie and Ruben Arts
great sleuthing @Petzep, thanks! It's great to have a comprehenisble explanation, hopefully that reveals a path to a fix.
Only new bit I can add to the conversation is that this is not console software dependent. It happens for me in CMD and Powershell, and doesn't matter if run within default Windows, Windows Terminal or ConEmu.
At least on my environments, the activation of pixi on windows take ~1/2 seconds, that makes it complicated to use pixi run as a replacement to pixi shell for terminal-intensive workflows. As I would really like to use pixi in some projects in which there is an extensive use of Windows, I am not currently exploring the workaround of using conda to activate the pixi environment:
conda activate .pixi/envs/default
That is far from perfect (you are basically ignoring the activation table of pixi.toml), but at least works with Ctrl+C .
Another alternative is to use https://github.com/synapticarbors/pixi2ces to create a conda lock file and create a different conda environment, but to be honest I do not love it as it as the same downside of the previous method, with the additional overhead of having a different conda environment, that can quickly diverse from the pixi one unless you pay attention.
Activity
[-]Powershell fails every command in pixi shell after cancelling (ctrl+c) one[/-][+]Powershell fails every command in pixi shell after cancelling (ctrl+c)[/+][-]Powershell fails every command in pixi shell after cancelling (ctrl+c)[/-][+]Powershell fails every prompt in pixi shell after cancelling (ctrl+c)[/+]ruben-arts commentedon Nov 28, 2023
I can recreate it! Will take a look at this later.
ruben-arts commentedon Dec 11, 2023
Added the help wanted label as we don't know where this is coming from.
traversaro commentedon Apr 14, 2024
I am experiencing this also on Command Prompt. Interestingly, it seems that the pixi environment is actually active when the prompt does not have the
(envname)modifier, while the(envname)modifier is present, the environment is not active, see :In this case,
pixiis version 0.18.0, andC:\src\pixitestis an empty pixi environment.traversaro commentedon Apr 29, 2024
This is particularly annoying as it appears to happen when you use Ctrl+C to close a running program, like:
I guess most users on Windows are probably using
pixi run, so they are not encountering this. I think I will eventually try to tackle this problem, as it is quite annoying. Anyone has some pointers to relevant part of the codes it may be worth start looking into?ruben-arts commentedon Apr 29, 2024
He @traversaro, please enlighten us!
The initialization of the powershell can be found here:
pixi/src/cli/shell.rs
Lines 37 to 70 in 58ab590
This is the prompt:
pixi/src/prompt.rs
Lines 37 to 43 in 58ab590
This is all the code around activation: https://github.com/prefix-dev/pixi/blob/main/src/activation.rs
Would be happy to help if you feel like you found the culprit!
Petzep commentedon May 1, 2024
I have the same issue.
When the terminal is corrupted, it behaves as if it is running both the
pixi-shelland thepowershellon the foreground.The input from the keyboard is sent to the
pixi-shellandpowershellon alternating keystrokes.This can be demonstrated by getting the process ID of powershell and the
pixi-shell, then corrupting thepixi-shelland checking thepids of both processes.Steps:
echo $pidpixi shellecho $pidsleep(1000)Enter and within 1 seconds Ctrl + Cecho $pidbut type every keystroke twicePS>and(pixi-env)PS>Are there any Ctrl + C hooks that could cause this behavior in the
pixi-shell?maphew commentedon May 30, 2024
great sleuthing @Petzep, thanks! It's great to have a comprehenisble explanation, hopefully that reveals a path to a fix.
Only new bit I can add to the conversation is that this is not console software dependent. It happens for me in CMD and Powershell, and doesn't matter if run within default Windows, Windows Terminal or ConEmu.
traversaro commentedon Aug 22, 2024
At least on my environments, the activation of pixi on windows take ~1/2 seconds, that makes it complicated to use
pixi runas a replacement topixi shellfor terminal-intensive workflows. As I would really like to use pixi in some projects in which there is an extensive use of Windows, I am not currently exploring the workaround of usingcondato activate the pixi environment:That is far from perfect (you are basically ignoring the
activationtable of pixi.toml), but at least works with Ctrl+C .Another alternative is to use https://github.com/synapticarbors/pixi2ces to create a conda lock file and create a different conda environment, but to be honest I do not love it as it as the same downside of the previous method, with the additional overhead of having a different conda environment, that can quickly diverse from the pixi one unless you pay attention.
ruben-arts commentedon Aug 22, 2024
Does `eval "$(pixi shell-hook -s bash)" work?
traversaro commentedon Aug 22, 2024
Probably this is more related to #417 ?
Anyhow, I just tried and it hangs for ~1/2 seconds, and then it exists but it does not seem to me that the environemnt is actually activated.
traversaro commentedon Aug 22, 2024
Actually the environment is activated, but the
PATHvariable does not contain the pixi-related parts.ruben-arts commentedon Aug 22, 2024
Ah because of that, issue in #417 with the path...
arthur-st commentedon Oct 12, 2024
Running into this as well, both in the command prompt and in PowerShell. The simplest repo is like this:
pixi shellpythonCMD will show an incorrectly exited Python interpreter, whereas PowerShell will just lock up after a few Enter presses (on a beefy machine).
fix: bind ctrl c listener so that it doesn't interfere on powershell (p…
traversaro commentedon Jan 29, 2025
@Luca0101 noticed again this problem in 0.40.2, we are investigating the problem and if we are able to reproduce we will open a new issue.
traversaro commentedon Jan 30, 2025
We isolated the problem, it appears to be a regression of 0.40.1 w.r.t. to 0.40.0, we reported it in #3037 .