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

Powershell completions broken #322

Closed
2 tasks done
Hofer-Julian opened this issue Sep 5, 2023 · 4 comments
Closed
2 tasks done

Powershell completions broken #322

Hofer-Julian opened this issue Sep 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Hofer-Julian
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

Add-Content -Path $PROFILE -Value 'Invoke-Expression (&pixi completion --shell powershell)'

Issue description

This has two problems:

  • It doesn't add a newline beforehand, which will not work if your profile isn't empty
  • If that is fixed it still fails with the following when starting up powershell:
Invoke-Expression : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Command'. Specified method is not supported.
At C:\Users\hofer_jn\OneDrive - Stichting Deltares\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:1 char:19
+ Invoke-Expression (&pixi completion --shell powershell)
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.InvokeExpressionCommand

Could reproduce with powershell 6 and 7

Expected behavior

Completions to work :)

@Hofer-Julian Hofer-Julian added the bug Something isn't working label Sep 5, 2023
@chawyehsu
Copy link
Contributor

The right way to register completions for pwsh is adding this to your $PROFILE:

(& pixi completion --shell powershell) | Out-String | Invoke-Expression

or by running:

Add-Content -Path $PROFILE -Value '(& pixi completion --shell powershell) | Out-String | Invoke-Expression'

@baszalmstra
Copy link
Contributor

@chawyehsu nice! Would you be able to create a PR to update the install script?

@chawyehsu
Copy link
Contributor

#325 ready

@Hofer-Julian
Copy link
Contributor Author

Can confirm that this solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants