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
Depending on the particular setup, the installation either doesn't work as documented (incorrect profile file, so it has no effect) or causes an error when a new PowerShell instance is opened, if the profile file is correct but not empty (in my case, it contained the single line Import-Module posh-git):
ParserError: D:\Users\<xxxxxxxx>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:4
Line |
4 | using namespace System.Management.Automation
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| A 'using' statement must appear before any other statements in a script.
For completeness sake, the output of pwsh --version is PowerShell 7.3.1
Steps
Use the new PowerShell pwsh instead of the bundled PowerShell OR have your Documents library set to a different path
Install rustup PowerShell completions by following the instructions given by rustup completions --help
Test-Path$profile# shows, true, so I skip New-Item -path $profile -type file -force
rustup completions powershell >>${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Open a new PowerShell instance and try to use the completions
Possible Solution(s)
On my system, ${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 does not match $profile (or $profile.CurrentUserAllHosts). So in general, the command has no effect except creating an unused file. At the very, least, the documentation should be corrected to suggest running rustup completions powershell >> $profile and remove the text about New-Item -path $profile -type file -force creating the above file (it doesn't).
Since the generated completions are incompatible with a non-empty profile, I would go further to remove the suggestion of appending to the profile entirely, and suggest something like:
Addendum: Instead of $profile which evaluates to $profile.CurrentUserCurrentHost, it may make sense to also suggest $profile.CurrentUserAllHosts as an alternative, although even that will not necessarily affect all PowerShell versions, since pwsh has its profile files under D:\Users\<xxxxxxxx>\Documents\PowerShell\ for me, while the bundled powershell has its profiles under D:\Users\<xxxxxxxx>\Documents\WindowsPowerShell\, neither of which matches the documented ${env:USERPROFILE}\Documents\WindowsPowerShell because I have my Documents library on a different drive:
Notes
Regarding the second part of the bug, I have attempted to move the output into a separate file rustup_completions.ps1 in the same directory as my profile script and sourcing it via . "$PSScriptRoot\rustup_completions.ps1". This still has no effect. The code is definitely run as checked by adding a Write-Output to the script, suggesting a third part to this bug. Update: The completions work when written to a separate file and sourced, but partial completions are unsupported since rustup uses clap 2 and partial completions are only supported since 3.0.6. This annoyance would be solved with #3094
Rustup version
rustup 1.25.1 (bb60b1e89 2022-07-12)info: This is the version for the rustup toolchain manager, not the rustc compiler.info: The currently active `rustc` version is `rustc 1.66.0 (69f9c33d7 2022-12-12)`
Installed toolchains
Default host: x86_64-pc-windows-msvcrustup home: C:\Users\<xxxxxxxx>\.rustupinstalled toolchains--------------------stable-x86_64-pc-windows-msvcnightly-x86_64-pc-windows-msvc1.34.0-x86_64-pc-windows-msvcinstalled targets for active toolchain--------------------------------------armv7-unknown-linux-gnueabihfnvptx64-nvidia-cudathumbv6m-none-eabiwasm32-wasix86_64-pc-windows-gnux86_64-pc-windows-msvcactive toolchain----------------stable-x86_64-pc-windows-msvc (default)rustc 1.66.0 (69f9c33d7 2022-12-12)
The text was updated successfully, but these errors were encountered:
Problem
Depending on the particular setup, the installation either doesn't work as documented (incorrect profile file, so it has no effect) or causes an error when a new PowerShell instance is opened, if the profile file is correct but not empty (in my case, it contained the single line
Import-Module posh-git
):For completeness sake, the output of
pwsh --version
isPowerShell 7.3.1
Steps
Use the new PowerShell
pwsh
instead of the bundled PowerShell OR have your Documents library set to a different pathInstall rustup PowerShell completions by following the instructions given by
rustup completions --help
Open a new PowerShell instance and try to use the completions
Possible Solution(s)
On my system,
${env:USERPROFILE}\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
does not match$profile
(or$profile.CurrentUserAllHosts
). So in general, the command has no effect except creating an unused file. At the very, least, the documentation should be corrected to suggest runningrustup completions powershell >> $profile
and remove the text aboutNew-Item -path $profile -type file -force
creating the above file (it doesn't).Since the generated completions are incompatible with a non-empty profile, I would go further to remove the suggestion of appending to the profile entirely, and suggest something like:
Addendum: Instead of
$profile
which evaluates to$profile.CurrentUserCurrentHost
, it may make sense to also suggest$profile.CurrentUserAllHosts
as an alternative, although even that will not necessarily affect all PowerShell versions, sincepwsh
has its profile files underD:\Users\<xxxxxxxx>\Documents\PowerShell\
for me, while the bundledpowershell
has its profiles underD:\Users\<xxxxxxxx>\Documents\WindowsPowerShell\
, neither of which matches the documented${env:USERPROFILE}\Documents\WindowsPowerShell
because I have my Documents library on a different drive:Notes
Regarding the second part of the bug, I have attempted to move the output into a separate fileUpdate: The completions work when written to a separate file and sourced, but partial completions are unsupported since rustup uses clap 2 and partial completions are only supported since 3.0.6. This annoyance would be solved with #3094rustup_completions.ps1
in the same directory as my profile script and sourcing it via. "$PSScriptRoot\rustup_completions.ps1"
. This still has no effect. The code is definitely run as checked by adding aWrite-Output
to the script, suggesting a third part to this bug.Rustup version
Installed toolchains
The text was updated successfully, but these errors were encountered: