-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix(cli): resolve relative paths and tilde for local config switching #8451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cli): resolve relative paths and tilde for local config switching #8451
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 4 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="extensions/cli/src/configLoader.ts">
<violation number="1" location="extensions/cli/src/configLoader.ts:578">
Home-directory expansion only handles "~/", so a Windows path like "~\config.yaml" is still left unresolved and the CLI looks in a literal "~" folder. Please handle both path separators to finish closing this bug.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| */ | ||
| function resolveFilePath(filePath: string): string { | ||
| // Handle tilde (~) expansion for home directory | ||
| if (filePath.startsWith("~/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Home-directory expansion only handles "/", so a Windows path like "\config.yaml" is still left unresolved and the CLI looks in a literal "~" folder. Please handle both path separators to finish closing this bug.
Prompt for AI agents
Address the following comment on extensions/cli/src/configLoader.ts at line 578:
<comment>Home-directory expansion only handles "~/", so a Windows path like "~\config.yaml" is still left unresolved and the CLI looks in a literal "~" folder. Please handle both path separators to finish closing this bug.</comment>
<file context>
@@ -569,15 +570,32 @@ function isFilePath(configPath: string): boolean {
+ */
+function resolveFilePath(filePath: string): string {
+ // Handle tilde (~) expansion for home directory
+ if (filePath.startsWith("~/")) {
+ return path.join(os.homedir(), filePath.slice(2));
+ }
</file context>
| if (filePath.startsWith("~/")) { | |
| if (filePath.startsWith("~/") || filePath.startsWith("~\\")) { |
Fix: CLI Local Config Path Resolution
Summary
Fixes a bug where switching to/from local configuration files would fail in the Continue CLI. The issue occurred because relative paths and tilde expansion were not being resolved to absolute paths before creating
file://URIs, resulting in invalid URIs likefile://./config.yaml.Problem
Users reported that config switching would fail when involving local config files:
The root cause was in the URI creation logic which didn't properly handle:
./config.yaml,../config.yaml~/.continue/config.yamlSolution
Added a
resolveFilePath()helper function that:~) to the user's home directorypath.resolve()Updated two key functions:
getUriFromSource()inconfigLoader.tspathToUri()inauth/uriUtils.tsBoth now ensure all file paths are absolute before creating
file://URIs.Changes
resolveFilePath()helper inconfigLoader.tsresolveFilePath()helper inauth/uriUtils.tsgetUriFromSource()to use path resolutionpathToUri()to use path resolutionuriUtils.test.tslocal-config-switching.test.tsxdocumentationTest Coverage
Added tests for:
./,../)~/)C:\, UNC paths)Example Before/After
Before (Broken)
After (Fixed)
Impact
Testing Instructions
./my-config.yamlcn chat --config ./my-config.yaml "test"cn chat --config continuedev/default-agent "test"cn chat --config ~/my-config.yaml "test"All switches should work without errors.
Related Issues
This fix addresses the documented issue in
/extensions/cli/src/e2e/local-config-switching.test.tsxwhere local config switching was identified as broken.Checklist
Summary by cubic
Fixes CLI config switching by resolving relative paths and tilde to absolute paths before creating file:// URIs. Remote↔Local and Local↔Local switches now work reliably across OSes.