-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all issues/PRs to ensure it has not already been reported or fixed.
- I have verified that I am using the latest version of Scoop and corresponding bucket.
Package Name
pwsh
Expected/Current Behaviour
Ideal Expected
I expect scoop.cmd update pwsh should work without failing about existing pwsh process.
Workaround Expectation
If fixing this is not possible, then a better error message would be appreciated! Right now the text "Since Scoop uses pwsh.exe internally, to update PowerShell Core itself, run scoop update pwsh from Windows PowerShell, i.e. powershell.exe." never showed when the error happened. Instead, it only showed up after successfully updating :\
I'd come back to #3572 multiple times trying to debug this problem, not realizing the difference between scoop.cmd and scoop (which defaults to scoop.ps1)
Steps to Reproduce
(Assuming your scoop pwsh package is out of date. Don't have any pwsh instance running.)
Start as admin: powershell.exe
Running scoop.cmd fails but running scoop succeeded. I thought at first the difference was between install * vs. install pwsh but I think that's a red herring?
$ scoop.cmd update *
Updating one outdated app:
Updating 'pwsh' (7.3.7 -> 7.3.9)
Downloading new version
PowerShell-7.3.9-win-x64.zip (102.9 MB) [=====================================================================] 100%
Checking hash of PowerShell-7.3.9-win-x64.zip ... ok.
ERROR The following instances of "pwsh" are still running. Close them and try again.
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
79 49.84 115.49 9.97 11596 2 pwsh
$ get-process pwsh
get-process : Cannot find a process with the name "pwsh". Verify the process name and call the cmdlet again.
At line:1 char:1
+ get-process pwsh
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (pwsh:String) [Get-Process], ProcessCommandException
+ FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand
$ get-process -pid 11596
get-process : Cannot find a process with the process identifier 11596.
At line:1 char:1
+ get-process -pid 11596
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (11596:Int32) [Get-Process], ProcessCommandException
+ FullyQualifiedErrorId : NoProcessFoundForGivenId,Microsoft.PowerShell.Commands.GetProcessCommand
$ scoop.cmd update *
pwsh: 7.3.7 -> 7.3.9
Updating one outdated app:
Updating 'pwsh' (7.3.7 -> 7.3.9)
Downloading new version
Loading PowerShell-7.3.9-win-x64.zip from cache
Checking hash of PowerShell-7.3.9-win-x64.zip ... ok.
ERROR The following instances of "pwsh" are still running. Close them and try again.
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
75 45.48 107.74 5.17 11084 2 pwsh
$ scoop update pwsh
pwsh: 7.3.7 -> 7.3.9
Updating 'pwsh' (7.3.7 -> 7.3.9)
Downloading new version
Loading PowerShell-7.3.9-win-x64.zip from cache
Checking hash of PowerShell-7.3.9-win-x64.zip ... ok.
Uninstalling 'pwsh' (7.3.7)
Removing shim 'pwsh.shim'.
Unlinking ~\scoop\apps\pwsh\current
Installing 'pwsh' (7.3.9) [64bit] from main bucket
Loading PowerShell-7.3.9-win-x64.zip from cache
Extracting PowerShell-7.3.9-win-x64.zip ... done.
Running pre_install script...
Linking ~\scoop\apps\pwsh\current => ~\scoop\apps\pwsh\7.3.9
Creating shim for 'pwsh'.
Creating shortcut for PowerShell Core (pwsh.exe)
Persisting Microsoft.VSCode_profile.ps1
Persisting Microsoft.PowerShell_profile.ps1
Persisting profile.ps1
Running post_install script...
'pwsh' (7.3.9) was installed successfully!
-----
Since Scoop uses pwsh.exe internally, to update PowerShell Core itself,
run `scoop update pwsh` from Windows PowerShell, i.e. powershell.exe.
Add PowerShell Core as a explorer context menu by running:
'C:\Users\darth\scoop\apps\pwsh\current\install-explorer-context.reg'
For file context menu, run 'C:\Users\darth\scoop\apps\pwsh\current\install-file-context.reg'
$ Possible Solution
If scoop.cmd is being invoked by powershell.exe, this logic in scoop.cmd shim is unexected:
where /q pwsh.exe
if %errorlevel% equ 0 (
pwsh -noprofile -ex unrestricted -file "C:\Users\darth\scoop\apps\scoop\current\bin\scoop.ps1" %*
) else (
powershell -noprofile -ex unrestricted -file "C:\Users\darth\scoop\apps\scoop\current\bin\scoop.ps1" %*
)Instead, scoop.cmd could detect it is being run by powershell.exe and default to using powershell instead of pwsh
Scoop and Buckets Version
$ scoop --version
Current Scoop version:
v0.3.1 - Released at 2022-11-15
'extras' bucket:
0c4f010ef (HEAD -> master, origin/master, origin/HEAD) telegram: Update to version 4.11.6
'java' bucket:
5f716b9b (HEAD -> master, origin/master, origin/HEAD) temurin11-nightly-jre: Update to version 11.0.22-2.0.202311091817
'main' bucket:
8d31d3ed7 (HEAD -> master, origin/master, origin/HEAD) protoc-gen-grpc-web: Update to version 1.5.0Scoop Config
$ scoop config
show_update_log last_update scoop_branch scoop_repo
--------------- ----------- ------------ ----------
False 2023-11-09T20:07:40.5881960-08:00 master https://github.com/lukesampson/scoopPowerShell Version
$ $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.3570
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.3570
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1Additional Softwares
I had vscode open but I was careful that all terminal sessions were closed.