Skip to content

terminal-suggest: fix root directory check in npm and yarn package.json lookup - #347265

Merged
Megan Rogge (meganrogge) merged 1 commit into
microsoft:mainfrom
rudy-07:fix/terminal-suggest-package-json-root-loop
Nov 13, 2026
Merged

Megan Rogge (meganrogge) merged 1 commit into
microsoft:mainfrom
rudy-07:fix/terminal-suggest-package-json-root-loop

Conversation

@rudy-07

Copy link
Copy Markdown
Contributor

Fixes #326920

Problem

In extensions/terminal-suggest/src/completions/npm.ts and yarn.ts, the shell command used to locate package.json in parent directories checked whether $PWD equaled ' / ' instead of '/'. When terminal suggestions run in a directory that has no ancestor package.json, $PWD reaches the filesystem root /, which never matches ' / '. As a result, the loop never terminates and spawns runaway bash processes consuming 100% CPU.

Fix

Correct the root directory condition in the generator scripts for both npm and yarn completions to match [[ $PWD = '/' ]], consistent with npx.ts line 16 and yarn.ts line 395.

Verification

  1. Verified that bash -c "until [[ -f package.json ]] || [[ $PWD = '/' ]]; do cd ..; done; cat package.json" terminates immediately upon reaching the filesystem root when no package.json exists.
  2. Verified that the syntax and quote escaping match existing sibling completion specifications.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 06:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@meganrogge Megan Rogge (meganrogge) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ty!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

@meganrogge
Megan Rogge (meganrogge) added this pull request to the merge queue Nov 13, 2026
Merged via the queue into microsoft:main with commit 33f61ad Nov 13, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants