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] Execution policy error with scoop #357

Closed
dragonmkww opened this issue Apr 17, 2022 · 15 comments
Closed

[Bug] Execution policy error with scoop #357

dragonmkww opened this issue Apr 17, 2022 · 15 comments
Labels
invalid This doesn't seem right wontfix This will not be worked on

Comments

@dragonmkww
Copy link

I installed this with scoop, and set the alias "pacman" for "pacaptr". When I run "pacman -Syu" which should run "scoop update" it instead runs "powershell scoop update". This gives me an Execution Policy error and says that the file "C:\Users<user>\scoop\shims\scoop.ps1" is not digitally signed. My Execution Policy is set to "Bypass" so this error should never happen, right? Can you please help me fix this, because this looks really cool and I would love to try it out!

@rami3l
Copy link
Owner

rami3l commented Apr 17, 2022

@dragonmkww
Thanks for your feedback!

IIRC powershell scoop update is actually the right command, since scoop is not a launch-able subprocess.

Unfortunately, I don't have enough info to determine the root of the problem you have encountered...

There are a few things you can try though:
- Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser to ensure you have the good execution policy.
- Run powershell scoop update manually to ensure pacaptr is doing what it claims to do.
- If powershell scoop update doesn't work, maybe the problem is with your scoop installation. Does scoop update work instead?


The problem turns out to be the difference between pwsh and powershell, as discussed below.

@rami3l rami3l added the bug Something isn't working label Apr 17, 2022
@rami3l rami3l changed the title Permission Error [Bug] Execution policy error when using with scoop Apr 17, 2022
@dragonmkww

This comment was marked as duplicate.

@rami3l
Copy link
Owner

rami3l commented Apr 18, 2022

@dragonmkww
Thanks for your reply.

I'm not actively using Windows for the moment, but pacaptr does its job just using a thin wrapper layer around subprocesses, and on Windows IIRC it seems not possible to me to start a subprocess call with scoop. That's why I added powershell at the beginning: it's a valid subprocess that can launch scoop properly.

For the implementation details, all is in scoop.rs, and I do encourage you to experiment as you wish.

The subprocess call is represented simply with a slice of strings:

Cmd::new(&["powershell", "scoop", "update"])

Interestingly, the first time I tried to add support for scoop I did begin the call with scoop but it didn't work:

Cmd::new(&["scoop", "update"]).kws(kws).flags(flags),

Please also notice that our CI tests are working alright, and I did make sure that pacaptr works on my Windows 10 VM during my initial development period, and that's why I'm very curious about your actual situation:

scoop-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- name: Install scoop
shell: pwsh
run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
iwr -useb 'https://raw.githubusercontent.com/scoopinstaller/install/master/install.ps1' -outfile 'install.ps1'
.\install.ps1 -RunAsAdmin
(Resolve-Path ~\scoop\shims).Path >> $Env:GITHUB_PATH
- name: Verity scoop installation
run: |
powershell scoop help
Get-Command scoop
- name: Build
run: cargo build --verbose
- name: Run unit tests
run: cargo test tests --verbose
- name: Run smoke tests
run: cargo test scoop --verbose
- name: Run heavy tests
run: cargo test scoop --verbose -- --ignored

@rami3l
Copy link
Owner

rami3l commented Apr 18, 2022

@dragonmkww
Please indicate your Windows version, the powershell version (32/64 bit and version number, both the one in which you set the policy and the one pointed to by the command powershell), so that we can rule out the situation in which the powershell you ran and the powershell I launched weren't the same thing.

You can also do Get-ExecutionPolicy -List with and without powershell at the beginning to see the differences.

Thanks in advance :)


Possibly related:
https://stackoverflow.com/a/44247390 shows that launching powershell with extra args might be required.

@dragonmkww
Copy link
Author

dragonmkww commented Apr 18, 2022 via email

@dragonmkww

This comment was marked as duplicate.

@rami3l
Copy link
Owner

rami3l commented Apr 19, 2022

@dragonmkww
Sorry for saying so, but since I cannot reproduce your environment easily (it works on my Windows 10 VM, I don't know what could be the difference, and I cannot get a Windows 11 environment easily), I refuse to fix this bug in the blind.

It will be nice however if you can fork this repository and clone it, see what will work for you, and make a Pull Request back.

Of course, I'll be continuing my investigation on my side, but don't expect it to happen very soon.

Have a nice day, and good luck with the fix :D

@rami3l rami3l changed the title [Bug] Execution policy error when using with scoop [Bug] Execution policy error with scoop Apr 19, 2022
@rami3l
Copy link
Owner

rami3l commented Apr 19, 2022

@dragonmkww
BTW, could you please paste the output with the commands below?

  • Get-ExecutionPolicy -List
  • powershell Get-ExecutionPolicy -List
  • powershell scoop update, containing the execution policy error

Thanks in advance.

@lynzrand
Copy link
Contributor

Rough guess: since you're using PowerShell Core 7.x.x, its executable is named pwsh instead of powershell (which corresponds to the system-installed .NET Framework version).

I suggest @rami3l try using pwsh instead of powershell and see if it works.

@rami3l
Copy link
Owner

rami3l commented Apr 19, 2022

@dragonmkww
If @lynzrand got it right, I assume you'll get different outputs for

Get-ExecutionPolicy -List

and

powershell Get-ExecutionPolicy -List

. If that is the case, please make sure that you indeed ran

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

in powershell, and not in pwsh. After that, the issue should be resolved.


Many thanks to both of you! If this indeed closes this issue, I'll include an update in the README describing this pwsh thing.

@dragonmkww

This comment was marked as resolved.

@dragonmkww

This comment was marked as resolved.

@rami3l
Copy link
Owner

rami3l commented Apr 19, 2022

Closing as it's not a bug.

@rami3l rami3l closed this as completed Apr 19, 2022
@rami3l rami3l added invalid This doesn't seem right wontfix This will not be worked on and removed bug Something isn't working labels Apr 19, 2022
@dragonmkww
Copy link
Author

dragonmkww commented Apr 19, 2022 via email

@dragonmkww
Copy link
Author

dragonmkww commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants