Skip to content

Fix path.resolve() discarding staging prefix for leading-slash dest#248

Closed
cewert wants to merge 1 commit intorokucommunity:masterfrom
cewert:fix/path-resolve-leading-slash-regression
Closed

Fix path.resolve() discarding staging prefix for leading-slash dest#248
cewert wants to merge 1 commit intorokucommunity:masterfrom
cewert:fix/path-resolve-leading-slash-regression

Conversation

@cewert
Copy link
Copy Markdown

@cewert cewert commented Apr 10, 2026

PR #245 replaced string interpolation with path.resolve() in copyToStaging() and zipFolder(). When dest starts with /, path.resolve() silently discards the base staging path, causing EACCES: permission denied, mkdir '/source'.

Changes

  • Replace path.resolve() in copyToStaging() with defensive logic that checks if dest is already an absolute path under stagingPath (use as-is) or otherwise strips leading slashes and uses path.join()
  • Apply the same pattern in zipFolder() for zip entry path construction
  • Add 5 regression tests covering leading-slash dest values in both functions (stubbed and integration)
  • Maintain 100% code coverage

Replace path.resolve() with defensive logic in copyToStaging() and
zipFolder() so that dest values starting with "/" no longer silently
discard the base staging path. This regressed in 3.16.4 (PR rokucommunity#245).
@TwitchBronBron
Copy link
Copy Markdown
Member

Hey, thanks for this. I think the bug in the VS Code extension was caused by something slightly different, so I’m not sure this is the implementation I want to add. The absolute change made in #245 supports writing things outside of outDir and rootDir, which was necessary for when vscode users want to set outDir somewhere above the workspace folder. I think this PR would introduce some additional restrictions that we don't actually need.

I just opened #249 and rokucommunity/roku-debug#329 to resolve the vscode issue.

@cewert cewert closed this Apr 10, 2026
@cewert cewert deleted the fix/path-resolve-leading-slash-regression branch April 11, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants