79401368

Date: 2025-01-30 22:25:47
Score: 0.5
Natty:
Report link

Inspired by this post, the following code in the profile of PowerShell v7.5.0 worked like a charm:

    # A workaround for the issue  https://github.com/PowerShell/PowerShell/issues/24869
    function Invoke-CleanConda {
        $Env:_CE_M = $Env:_CE_CONDA = $null # need to be cleared each time before calling conda command
        Invoke-Conda @args # pass all the arguments to the conda command
    }
    Write-Output "`n"
    Write-Output "**********************************************************************"
    Write-Output "* HACK: Remove the default conda alias                               *"
    Write-Output "* and define a new command Invoke-CleanConda() as workaround.        *"
    Write-Output "**********************************************************************"
    Write-Output "`n"
    Remove-Alias conda # remove the default conda alias
    Invoke-CleanConda env list

Instead of calling conda [options], just call alll conda command with Invoke-CleanConda [options] such as

    Invoke-CleanConda activate base
    Invoke-CleanConda env list

Of course, it would be better to fix the PS init issue on the Conda side. Also added here https://github.com/PowerShell/PowerShell/issues/24869#issuecomment-2625708821

Reasons:
  • Blacklisted phrase (1): worked like a charm
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ting Li