fix: correct readFileSync calls in LinkInstaller to fix plugin installation#7467
fix: correct readFileSync calls in LinkInstaller to fix plugin installation#7467JohnMcLear merged 3 commits intodevelopfrom
Conversation
…lation pathToFileURL() was incorrectly wrapping paths passed to readFileSync(), causing ENOENT errors that were silently caught. Using plain paths with 'utf-8' encoding fixes plugin dependency resolution. Fixes #6811 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review Summary by QodoFix readFileSync calls in LinkInstaller for plugin installation
WalkthroughsDescription• Fixed incorrect pathToFileURL() wrapping in readFileSync() calls • Replaced with plain file paths and 'utf-8' encoding parameter • Removed unnecessary as unknown as string type casts • Removed unused pathToFileURL import from node:url Diagramflowchart LR
A["readFileSync with pathToFileURL"] -->|"Remove incorrect wrapping"| B["readFileSync with plain path"]
A -->|"Remove unused import"| C["Remove pathToFileURL import"]
A -->|"Remove type cast"| D["Remove as unknown as string"]
B -->|"Add encoding parameter"| E["Add utf-8 encoding"]
File Changes1. src/static/js/pluginfw/LinkInstaller.ts
|
Code Review by Qodo
1. Missing plugin install regression test
|
| try { | ||
| const json:IPluginInfo = JSON.parse( | ||
| readFileSync(pathToFileURL(path.join(pluginInstallPath, dependency, 'package.json'))) as unknown as string); | ||
| readFileSync(path.join(pluginInstallPath, dependency, 'package.json'), 'utf-8')); | ||
| if(json.dependencies){ |
There was a problem hiding this comment.
1. Missing plugin install regression test 📘 Rule violation ⚙ Maintainability
This PR changes plugin installation behavior in LinkInstaller to fix readFileSync() path handling, but it does not add a regression test that would fail without the fix. Without coverage, this bug can reappear unnoticed in future refactors.
Agent Prompt
## Issue description
A bug fix was made to plugin installation file reading logic, but there is no regression test ensuring the installer reads `package.json` via a filesystem path string (not a file URL) and with an explicit encoding.
## Issue Context
This change fixes plugin installation failures that previously manifested as `ENOENT` errors and/or ineffective dependency linking. A test should fail if the old `pathToFileURL()` + `readFileSync()` usage is reintroduced.
## Fix Focus Areas
- src/static/js/pluginfw/LinkInstaller.ts[94-201]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Covers the readFileSync fix from the plugin installation bug where pathToFileURL incorrectly wrapped file paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously dependenciesMap.set() ran after the catch block, marking dependencies as tracked even when linking or package.json reading failed. This blocked later cleanup via removeSubDependency(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
pathToFileURL()was incorrectly wrapping file paths passed toreadFileSync()inLinkInstaller.ts, causing ENOENT errors when reading pluginpackage.jsonfiles'utf-8'encoding, removed unnecessaryas unknown as stringcastsTest plan
pnpm run plugins i ep_markdownand verify it appears inpnpm run plugins lsFixes #6811
🤖 Generated with Claude Code