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

[Bug] fails in PowerShell Core 7.x (but works in PowerShell Classic 5.x) #832

Open
2 of 6 tasks
michaelgracious opened this issue Apr 5, 2024 · 9 comments
Open
2 of 6 tasks
Labels
bug Something isn't working has-workaround

Comments

@michaelgracious
Copy link

michaelgracious commented Apr 5, 2024

What were you trying to install (or what else went wrong)?

installing/updating ANY webi package

What exactly did you do?

Running webi webi for instance

What went wrong?

Running the this command using Windows Terminal (running powershell 7.4.1 or 7.5 preview) results in an error (any installer fails, just using webi webi as an example)

Set-ExecutionPolicy : The 'Set-ExecutionPolicy' command was found in the module 'Microsoft.PowerShell.Security', but
the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.
At C:\Users\thul\.local\tmp\webi.install.ps1:7 char:1
+ Set-ExecutionPolicy -Scope Process Bypass
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-ExecutionPolicy:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Windows Terminal is running version 1.20.10822.0

Might be related to PowerShell/PowerShell#18530 ?

Which OS did you try on?

  • Mac
  • Windows
  • Linux

What type of computer (i.e. laptop, desktop, Raspberry Pi)?

  • Laptop or Desktop (amd64 / x86-64)
  • Raspberry Pi (ARM-64)
  • Other (please specify, if you know)
@michaelgracious michaelgracious added the bug Something isn't working label Apr 5, 2024
@michaelgracious michaelgracious changed the title [Bug] webi does not install anyhing using powershell [Bug] webi does not install anything using powershell Apr 5, 2024
@coolaj86
Copy link
Member

coolaj86 commented May 3, 2024

Are you on a restricted user account? What version of Windows, PowerShell (powershell --version), and PowerShell Core (pwsh --version) do you have?

@michaelgracious
Copy link
Author

  1. User account is not restricted, i tried both admin privileged shell and normal shell
  2. As i stated in the issue im on Powershell 7.4.1
  3. Powershell core is 7.4 (i need to double check as im not at home now)

@coolaj86
Copy link
Member

Dusting off my Windows computer...

I can confirm in PowerShell Core 7.3.9 that running webi exits immediately - but I don't even get an error message of any kind.

I suppose that if I update from Windows 10.0.22000 (which is actually Windows 11) to the current version, I will probably be plagued with the same problem in PowerShell (native).

Perhaps I could add a try around Import-Module Microsoft.PowerShell.Security and see if it works forwards and backwards.

@coolaj86
Copy link
Member

@jkunkee Any idea how users can run scripts with the new PowerShell permission system?

@coolaj86
Copy link
Member

coolaj86 commented May 16, 2024

@michaelgracious What do you get for the output of this?

Get-ExecutionPolicy -List

I always thought it was stupid that for a script to get permissions to run, all it had to do was literally give itself permission to run as the first thing it did when it was running... but if they "fixed" that, well, then I don't think you can get scripts to run without going into admin settings.

Will you also try this?

Set-ExecutionPolicy -Scope Process Bypass
webi --help
webi webi

Meanwhile... I run upgrades...

@coolaj86 coolaj86 changed the title [Bug] webi does not install anything using powershell [Bug] webi errors out in PowerShell Core 7.x (still works in PowerShell Classic 5.x) May 17, 2024
@coolaj86 coolaj86 changed the title [Bug] webi errors out in PowerShell Core 7.x (still works in PowerShell Classic 5.x) [Bug] fails in PowerShell Core 7.x (but works in PowerShell Classic 5.x) May 17, 2024
@coolaj86
Copy link
Member

@michaelgracious I've finished updating Windows 11 ARM and it only brought my native PowerShell to 5.1.x, and Webi still works in that.

So it looks like PowerShell Core can't call out to powershell classic.

I think we may run into a problem where we have to detect whether it's PowerShell Classic or PowerShell Core...

@coolaj86
Copy link
Member

coolaj86 commented Jun 3, 2024

Some more notes:

From

Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass -File `"%USERPROFILE%\.local\bin\webi-pwsh.ps1`" %*"

~/.local/bin/webi.bat:

@echo off
powershell -ExecutionPolicy Bypass -File "%USERPROFILE%\.local\bin\webi-pwsh.ps1" %*

@coolaj86
Copy link
Member

coolaj86 commented Aug 20, 2024

ChatGPT happened to spit this out at me about how to install choco while I was doing some swift coding today:

Set-ExecutionPolicy Bypass -Scope Process -Force; `
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

I think that may be relevant to the distinction between security policies in PowerShell Classic and PowerShell Core, so I'm just plopping it down here for now.

@coolaj86
Copy link
Member

Also while I was looking up some info on bun, Brave Leo spat this out:

iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.1.6"

Maybe using iex or irm will help us in some way.

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

No branches or pull requests

2 participants