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 Profile fails with interactive prompt #59

Open
craftzneko opened this issue Mar 25, 2024 · 2 comments
Open

Powershell Profile fails with interactive prompt #59

craftzneko opened this issue Mar 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@craftzneko
Copy link

craftzneko commented Mar 25, 2024

Describe the bug

following your video guide posted here video guide here you run gh copilot alias --help and use the example for adding to powershell profile

# Add aliases to PowerShell profile
$ $GH_COPILOT_PROFILE = Join-Path -Path $(Split-Path -Path $PROFILE -Parent) -ChildPath "gh-copilot.ps1"
$ gh copilot alias -- pwsh | Out-File ( New-Item -Path $GH_COPILOT_PROFILE -Force )
$ echo ". $GH_COPILOT_PROFILE" >> $PROFILE

running these for the first time (as suggested as a first step in the video) results in interactive prompt being added to that file which then break the command string and actually overwrites $profile

these are added to the gh-copilot.ps1 file.

? Allow GitHub to collect optional usage data to help us improve? This data does not include your queries. [Use arrows to move, type to filter]

> Yes
> No

? Allow GitHub to collect optional usage data to help us improve? This data does not include your queries.

> Yes

Also i may have missed this but i dont see a requirement to have powershell 7.3 but your using a "Clean" block in the gh-copilot.ps1 which was only added in 7.3. I may have missed that requirement though

Steps to reproduce the behavior

  1. download CLI, authenticate
  2. run gh copilot alias --help
  3. run the command examples for powershell

Expected vs actual behavior

alias's are added to profile

@craftzneko craftzneko added bug Something isn't working needs-triage needs to be reviewed labels Mar 25, 2024
@craftzneko craftzneko changed the title [BUG]: Powershell Profile fails with interactive prompt Mar 25, 2024
@andyfeller
Copy link
Contributor

@craftzneko : thank you for opening this issue and apologies for any frustration this may have caused! ❤

I believe there are other issues we are tracking similar feedback already:

How would you suggest modifying the aliases for older PowerShell 7.x releases?

@andyfeller andyfeller removed the needs-triage needs to be reviewed label Mar 29, 2024
@craftzneko
Copy link
Author

@andyfeller my apologies i originally logged this over on the general gh repo and did search first but they then suggested I post here and I didn't search for existing issues open on this repo. If you want to target powershell desktop 5 you would need to refactor the code to remove commands not in 5 such as "Clean" block, assuming the actual extension will even work on 5. If it doesnt work on 5 i guess just put an if to check and prevent potentially breaking a users profile if they try and run it from 5

if ($PSVersionTable.PSVersion.Major -eq 5) {
    Write-Output "Ending as running in powershell 5"
}

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

2 participants