Skip to content

everything-alpha: Check properly for the existence of the Everything service#2279

Open
ymeine wants to merge 1 commit intoScoopInstaller:masterfrom
ymeine:issue-2216-everything-alpha-service-check
Open

everything-alpha: Check properly for the existence of the Everything service#2279
ymeine wants to merge 1 commit intoScoopInstaller:masterfrom
ymeine:issue-2216-everything-alpha-service-check

Conversation

@ymeine
Copy link
Copy Markdown

@ymeine ymeine commented Apr 29, 2025

In addition to what is described in the linked issue, it also fixes a few other things:

  • remove the right service during uninstall by using the service name gotten from PowerShell
  • stop only the processes linked to that application

Those fixes are meant to handle a proper cohabitation of different versions of Everything, no matter how many processes or services they each have.

Closes #2216

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced uninstall process to accurately identify and remove all related processes and services based on installation paths
    • Added administrator privilege verification before service removal
    • Improved error handling during uninstallation for edge cases

@github-actions
Copy link
Copy Markdown
Contributor

All changes look good.

Wait for review from human collaborators.

everything-alpha

  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

@HUMORCE
Copy link
Copy Markdown
Member

HUMORCE commented Jun 6, 2025

It should align with extras/everything.

@ymeine
Copy link
Copy Markdown
Author

ymeine commented Jun 6, 2025

@HUMORCE extras/everything has a different implementation which I think has the same issues as described in #2216.

I guess you meant the opposite then, that extras/everything should align with this new implementation of versions/everything-alpha?

In that case, do you mean that I should create an equivalent PR for extras/everything, so that you would eventually merge both around the same time to keep consistency?

If that is the case, the current PR here would require a proper review and approval first, so that work is not duplicated with the upcoming PR for extras/everything (otherwise comments and updates may come in twice).

@HUMORCE
Copy link
Copy Markdown
Member

HUMORCE commented Jun 6, 2025

In that case, do you mean that I should create an equivalent PR for extras/everything

Yes, label alpha-specific code with commented separately as possible, for better maintainability

…service (fix ScoopInstaller#2216)

In addition to what is described in the linked issue, it also fixes a few other things:

- remove the right service during uninstall by using the service name gotten from PowerShell
- stop only the processes linked to that application

Those fixes are meant to handle a proper cohabitation of different versions of Everything, no matter how many processes or services they each have.
@ymeine ymeine force-pushed the issue-2216-everything-alpha-service-check branch from 6f51e0e to b932106 Compare April 15, 2026 14:26
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Walkthrough

The pre_uninstall flow in everything-alpha.json has been enhanced to properly detect and handle the Everything service by using wildcard matching (Everything*), verifying that the service's BinaryPathName matches the installation directory pattern, and handling service operations safely only when the service actually exists and belongs to the current installation.

Changes

Cohort / File(s) Summary
Service Detection Fix
bucket/everything-alpha.json
Enhanced pre_uninstall logic to use Everything* wildcard pattern matching, validate service BinaryPathName against installation directory, properly handle cases where service does not exist or belongs to different installation, and enumerate all matching processes before stopping them.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A script now checks with care and grace,
To find the service in the right place.
With wildcards and paths, no more confusion,
Everything uninstalls without illusion!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description adequately explains the changes made (proper service detection, stopping only associated processes, enabling cohabitation of multiple versions) and includes the required checklist confirmation and closes reference.
Linked Issues check ✅ Passed The PR implementation addresses all primary coding requirements from issue #2216: enumerating services with pattern matching, validating the service belongs to the installation by checking BinaryPathName against the installation directory, and stopping only associated processes during uninstall.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to the objectives in issue #2216. The modifications focus on the pre_uninstall flow for everything-alpha to properly detect and handle the service, with no unrelated changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: improving the service detection logic in the pre_uninstall flow for Everything by matching services based on binary path and handling multiple service variants.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bucket/everything-alpha.json`:
- Around line 70-73: The uninstall branch calls sc.exe with an unquoted
$serviceName which will break for service names containing spaces or
parentheses; update the uninstall block where $serviceName is used (the "if
($cmd -eq 'uninstall')" branch invoking sc.exe) to pass the service name wrapped
in quotes (e.g., ensure the argument to sc.exe is "\"$serviceName\"" or the
equivalent quoting method your PowerShell script uses) so sc.exe receives the
full name as a single argument.
- Around line 40-45: The pipeline continuation is broken because the pipe is on
the next line and $processes.Length is unreliable for single items; change the
pipeline so the pipe is at the end of the Get-Process line (i.e., Put the "|" at
the end of the Get-Process command before Where-Object) and replace uses of
$processes.Length with an explicit array-wrapping count like
@($processes).Count; update the block that uses $processes (the foreach and
Stop-Process calls) to operate on the same corrected $processes variable.
- Around line 47-58: The service-detection block using Get-Service and
$appPathPattern is broken by a leading pipe and treats $services unreliably as a
scalar; fix it by ensuring the pipeline operator is at the end of the
Get-Service line (or wrap the whole pipeline in @(...)) and coerce results into
an array with @(...): call Get-Service -Name Everything* -ErrorAction
SilentlyContinue | Where-Object { $_.BinaryPathName -match $appPathPattern }
inside @(...) so $services = @(...), then replace .Length checks with array-safe
checks (e.g. ($services).Count or test array membership) and replace direct
indexing $services[0] with stable access after the @(...) coercion so single
results are handled correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 18ddf746-ab0e-439a-bff8-5fa3d031d40c

📥 Commits

Reviewing files that changed from the base of the PR and between 41d488f and b932106.

📒 Files selected for processing (1)
  • bucket/everything-alpha.json

Comment on lines +40 to 45
"$processes = Get-Process -Name 'everything' -ErrorAction SilentlyContinue",
" | Where-Object { $_.Path -match $appPathPattern }",
"info \"Found $($processes.Length) Everything process(es) to stop\"",
"foreach ($process in $processes) {",
" Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue",
"}",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Pipeline continuation will not work with | at the start of a new line.

In PowerShell, when the previous line is a complete statement (like an assignment), placing | at the start of the next line does not continue the pipeline—it either causes a syntax error or operates on $null. The pipe must be at the end of the preceding line.

Additionally, $processes.Length is unreliable because PowerShell doesn't wrap single objects in an array; .Length on a single Process object returns $null or a string length, not 1. Use @(...).Count to force array context.

Proposed fix
-        "$processes = Get-Process -Name 'everything' -ErrorAction SilentlyContinue",
-        "    | Where-Object { $_.Path -match $appPathPattern }",
-        "info \"Found $($processes.Length) Everything process(es) to stop\"",
+        "$processes = @(Get-Process -Name 'everything' -ErrorAction SilentlyContinue |",
+        "    Where-Object { $_.Path -match $appPathPattern })",
+        "info \"Found $($processes.Count) Everything process(es) to stop\"",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"$processes = Get-Process -Name 'everything' -ErrorAction SilentlyContinue",
" | Where-Object { $_.Path -match $appPathPattern }",
"info \"Found $($processes.Length) Everything process(es) to stop\"",
"foreach ($process in $processes) {",
" Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue",
"}",
"$processes = @(Get-Process -Name 'everything' -ErrorAction SilentlyContinue |",
" Where-Object { $_.Path -match $appPathPattern })",
"info \"Found $($processes.Count) Everything process(es) to stop\"",
"foreach ($process in $processes) {",
" Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue",
"}",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bucket/everything-alpha.json` around lines 40 - 45, The pipeline continuation
is broken because the pipe is on the next line and $processes.Length is
unreliable for single items; change the pipeline so the pipe is at the end of
the Get-Process line (i.e., Put the "|" at the end of the Get-Process command
before Where-Object) and replace uses of $processes.Length with an explicit
array-wrapping count like @($processes).Count; update the block that uses
$processes (the foreach and Stop-Process calls) to operate on the same corrected
$processes variable.

Comment on lines +47 to +58
"$services = Get-Service -Name Everything* -ErrorAction SilentlyContinue",
" | Where-Object { $_.BinaryPathName -match $appPathPattern }",
"",
"if ($services.Length -gt 1) {",
" error 'Multiple Everything services found, this is likely a bug with this manifest.'",
" break",
"} elseif ($services.Length -eq 0) {",
" info 'No Everything service found, continuing with uninstall.'",
"} else {",
" $service = $services[0]",
" $serviceName = $service.Name",
" info \"Found Everything service: $serviceName\"",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Same pipeline continuation and array-handling issues in service detection.

Lines 47-48 have the same broken pipeline continuation (pipe at start of new line). Lines 50, 53 use .Length which is unreliable, and line 56's $services[0] will fail when PowerShell returns a single ServiceController object (not an array).

Wrap in @(...) to ensure array context throughout.

Proposed fix
-        "$services = Get-Service -Name Everything* -ErrorAction SilentlyContinue",
-        "    | Where-Object { $_.BinaryPathName -match $appPathPattern }",
+        "$services = @(Get-Service -Name Everything* -ErrorAction SilentlyContinue |",
+        "    Where-Object { $_.BinaryPathName -match $appPathPattern })",
         "",
-        "if ($services.Length -gt 1) {",
+        "if ($services.Count -gt 1) {",
             "error 'Multiple Everything services found, this is likely a bug with this manifest.'",
             "break",
-        "} elseif ($services.Length -eq 0) {",
+        "} elseif ($services.Count -eq 0) {",
             "info 'No Everything service found, continuing with uninstall.'",
         "} else {",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"$services = Get-Service -Name Everything* -ErrorAction SilentlyContinue",
" | Where-Object { $_.BinaryPathName -match $appPathPattern }",
"",
"if ($services.Length -gt 1) {",
" error 'Multiple Everything services found, this is likely a bug with this manifest.'",
" break",
"} elseif ($services.Length -eq 0) {",
" info 'No Everything service found, continuing with uninstall.'",
"} else {",
" $service = $services[0]",
" $serviceName = $service.Name",
" info \"Found Everything service: $serviceName\"",
"$services = @(Get-Service -Name Everything* -ErrorAction SilentlyContinue |",
" Where-Object { $_.BinaryPathName -match $appPathPattern })",
"",
"if ($services.Count -gt 1) {",
" error 'Multiple Everything services found, this is likely a bug with this manifest.'",
" break",
"} elseif ($services.Count -eq 0) {",
" info 'No Everything service found, continuing with uninstall.'",
"} else {",
" $service = $services[0]",
" $serviceName = $service.Name",
" info \"Found Everything service: $serviceName\"",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bucket/everything-alpha.json` around lines 47 - 58, The service-detection
block using Get-Service and $appPathPattern is broken by a leading pipe and
treats $services unreliably as a scalar; fix it by ensuring the pipeline
operator is at the end of the Get-Service line (or wrap the whole pipeline in
@(...)) and coerce results into an array with @(...): call Get-Service -Name
Everything* -ErrorAction SilentlyContinue | Where-Object { $_.BinaryPathName
-match $appPathPattern } inside @(...) so $services = @(...), then replace
.Length checks with array-safe checks (e.g. ($services).Count or test array
membership) and replace direct indexing $services[0] with stable access after
the @(...) coercion so single results are handled correctly.

Comment on lines +70 to +73
" if ($cmd -eq 'uninstall') {",
" info 'Removing service'",
" sc.exe delete $serviceName",
" }",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Quote $serviceName when calling sc.exe to handle names with spaces.

Per issue #2216, service names like "Everything (1.5a)" contain spaces and parentheses. Passing $serviceName unquoted to sc.exe will cause the command to fail. Wrap in quotes.

Proposed fix
-        "sc.exe delete $serviceName",
+        "sc.exe delete `\"$serviceName`\"",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bucket/everything-alpha.json` around lines 70 - 73, The uninstall branch
calls sc.exe with an unquoted $serviceName which will break for service names
containing spaces or parentheses; update the uninstall block where $serviceName
is used (the "if ($cmd -eq 'uninstall')" branch invoking sc.exe) to pass the
service name wrapped in quotes (e.g., ensure the argument to sc.exe is
"\"$serviceName\"" or the equivalent quoting method your PowerShell script uses)
so sc.exe receives the full name as a single argument.

@z-Fng z-Fng changed the title everything-alpha: check properly for the existence of the Everything service (fix #2216) everything-alpha: Check properly for the existence of the Everything service Apr 17, 2026
" sc.exe delete 'Everything'",
"",
"$services = Get-Service -Name Everything* -ErrorAction SilentlyContinue",
" | Where-Object { $_.BinaryPathName -match $appPathPattern }",
Copy link
Copy Markdown
Member

@z-Fng z-Fng Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pipeline continuation will not work with | at the start of a new line.

I can reproduce this issue on PowerShell 5. And the BinaryPathName property is inaccessible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: everything-alpha does not check properly for the existence of the Everything service

3 participants