[Bug] expandPath in path-utils.ts produces mixed path separators on Windows (same pattern as #1442) #1469
RelaxJonh
started this conversation in
Bug reports
Replies: 1 comment
|
Prepared a fix on my fork: https://github.com/RelaxJonh/prime-agent/tree/fix/expand-path-mixed-separators The fix adds - import { isAbsolute, resolve as resolvePath } from "node:path";
+ import { isAbsolute, join, resolve as resolvePath } from "node:path";
if (normalized.startsWith("~/")) {
- return os.homedir() + normalized.slice(1);
+ return join(os.homedir(), normalized.slice(1));
}This matches the pattern already used in |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Affected area
Coding agent —
packages/coding-agent/src/core/tools/path-utils.tsWhat happened?
expandPath()inpath-utils.ts(line 45) has the same mixed-separator bug as #1442 (expandTildePathinconfig.ts):On Windows,
os.homedir()returnsC:\Users\username(backslashes) andnormalized.slice(1)returns/Documents(forward slash from the tilde path). The concatenation producesC:\Users\username/Documents— mixed separators.Comparison with correct implementations
The same repo has correct implementations using
path.join:extensions/loader.ts:93:path.join(os.homedir(), normalized.slice(2))✓prompt-templates.ts:193:join(homedir(), trimmed.slice(2))✓Steps to reproduce
~/some/pathexpandPath("~/some/path")returnsC:\Users\user/some/pathpath.resolvemay failSuggested fix
if (normalized.startsWith("~/")) { - return os.homedir() + normalized.slice(1); + return path.join(os.homedir(), normalized.slice(1)); }This is the same fix pattern as #1442 for
config.ts:expandTildePath.Environment
All reactions