Cannot add config as new file (filepath error on windows)
Before submitting your bug report
- [x] I believe this is a bug. I'll try to join the Continue Discord for questions
- [x] I'm not able to find an open issue that reports the same bug
- [x] I've seen the troubleshooting guide on the Continue Docs
Relevant environment info
- OS: Window 11
- Continue version: 1.0.8 & 1.0.9
- IDE version: 1.100.0
- Model:
- config:
OR link to assistant in Continue hub:
Description
No response
To reproduce
- Click to
Add Ruleson chat user input block - New file to set the rule (path like D:/project/new-rules.yaml)
- Back to the rule list, that new one file doesn't load successfully.
Log output
ENOENT: no such file or directory, open 'C:\d:\project.continue\rules\new-rule.yaml'
The file path is file:///d/.....
may be problems function is getContentFromFilePath() in registryClient.ts
need to slice 8 characters instead of 7.
same problem here. Adding new configurations give out errors:
This is the error that continue shows me in VSCode (notice the "C:\C:" in the path. It's adding an extra "C:" in both of our cases (me and asus-ocis)):
ENOENT: no such file or directory, open 'C:\C:\Users\UserName.continue\assistants\config-2.yaml' Error: ENOENT: no such file or directory, open 'C:\C:\Users\UserName.continue\assistants\config-2.yaml' at Object.readFileSync (node:fs:451:20) at Object.t.readFileSync (node:electron/js2c/node_init:2:10175) at RegistryClient.getContentFromFilePath (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:125902:22) at RegistryClient.getContent (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:125892:25) at unrollAssistant (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:125635:38) at loadConfigYaml (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:634193:9) at loadContinueConfigFromYaml (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:634481:28) at doLoadConfig (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:634577:21) at _LocalProfileLoader.doLoadConfig (c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:634812:25) at c:\Users\UserName.vscode\extensions\continue.continue-1.0.9-win32-x64\out\extension.js:635004:23
And I got a different but similar error on the Output tab, on the "Window" option in the dropdown menu (I believe they are related):
2025-05-13 10:30:21.140 [error] [Window] [Extension Host] Failed to unroll block [object Object]: ENOENT: no such file or directory, open 'C:\Users\UserName\AppData\Local\Programs\Microsoft VS Code\vscode-remote:\dev-container%2Bsome-long-number@ssh-remote%2B111.111.111.111\workspaces\Angular_learn.continue\docs\new-doc.yaml'
If I could patch it myself, I would, but I don't think my knowledge is good enough, yet. I could trace it to the js file and check the code, but ... I didn't know how to set up breakpoints in a currently running block of code, sorry!!
I tried something silly based on what asus-ocis said...
may be problems function is getContentFromFilePath() in registryClient.ts need to slice 8 characters instead of 7.
I did edit directly the file extension.js
and tried slice values like 10 and 4 characters (three more and three less because "c:" are 3 chars and I'm not sure if slice counts left to right or right to left.) but it didn't work, maybe because the file extension.js is transpiled from some other ts file everytime I refresh ... I don't know (ts is not my language, sorry!)
I also get this error (which I think happens because it is unable to find the correct config.yaml and it defaults to config.json (but that is not right, obviously. If the yaml file is not there, is good to use the json as fallback, but ... if the yaml file is there but is not able to pick it up because the path is wrong, then ... there is the issue V_V).
PS: I hope this helps somehow, thanks for your hard work.
Ok, I was able to patch the extension.js and it works (chatGPT solution, but it works):
I'm on Version 1.1.34 Windows 10 and probably latest version of VSCode whatever it is. (all of that doesn't matter because previous versions didn't work either. The only difference would be being on Windows or Linux tbh).
This is the original code in extension.js line 125904:
getContentFromFilePath(filepath) {
if (filepath.startsWith("file://")) {
const pathWithoutProtocol = filepath.slice(7);
return fs8.readFileSync(decodeURIComponent(pathWithoutProtocol), "utf8");
} else if (path2.isAbsolute(filepath)) {
return fs8.readFileSync(filepath, "utf8");
} else if (this.rootPath) {
return fs8.readFileSync(path2.join(this.rootPath, filepath), "utf8");
} else {
throw new Error("No rootPath provided for relative file path");
}
}
this is the patched version in extension.js same line (125904):
getContentFromFilePath(filepath) {
if (filepath.startsWith("file://")) {
const normalizedPath = fileURLToPath(filepath);
return fs8.readFileSync(normalizedPath, "utf8");
} else if (path2.isAbsolute(filepath)) {
return fs8.readFileSync(filepath, "utf8");
} else if (this.rootPath) {
return fs8.readFileSync(path2.join(this.rootPath, filepath), "utf8");
} else {
throw new Error("No rootPath provided for relative file path");
}
}
for that to work, you also need to add this line (const { fileURLToPath } = require('url');) at the beginning of the file (line 67) right after the __privateMethod block:
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};
// scripts/importMetaUrl.js
var importMetaUrl;
var init_importMetaUrl = __esm({
"scripts/importMetaUrl.js"() {
"use strict";
importMetaUrl = require("url").pathToFileURL(__filename);
}
});
this is the patched version same line (67)
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};
const { fileURLToPath } = require('url');
// scripts/importMetaUrl.js
var importMetaUrl;
var init_importMetaUrl = __esm({
"scripts/importMetaUrl.js"() {
"use strict";
importMetaUrl = require("url").pathToFileURL(__filename);
}
});
And this would be the typescript correction (as ChatGPT mentions. Double check for bugs):
inside registryClient.ts replace this:
private getContentFromFilePath(filepath: string): string {
if (filepath.startsWith("file://")) {
const pathWithoutProtocol = filepath.slice(7);
// For Windows file:///C:/path/to/file, we need to handle it properly
// On other systems, we might have file:///path/to/file
return fs.readFileSync(decodeURIComponent(pathWithoutProtocol), "utf8");
} else if (path.isAbsolute(filepath)) {
return fs.readFileSync(filepath, "utf8");
} else if (this.rootPath) {
return fs.readFileSync(path.join(this.rootPath, filepath), "utf8");
} else {
throw new Error("No rootPath provided for relative file path");
}
}
with this (the first line goes with all the imports in ts):
import { fileURLToPath } from 'url';
...
if (filepath.startsWith("file://")) {
const normalizedPath = fileURLToPath(filepath); // this handles everything
return fs8.readFileSync(normalizedPath, "utf8");
} else if (path.isAbsolute(filepath)) {
return fs.readFileSync(filepath, "utf8");
} else if (this.rootPath) {
return fs.readFileSync(path.join(this.rootPath, filepath), "utf8");
} else {
throw new Error("No rootPath provided for relative file path");
}
ChatGPT says that it can replace the whole if / else block, but I'm unsure if that would work, it would require for me to do tests on linux and whatnot. I've only patched what I needed.
I hope the js code helps everyone for a quick patch, and this ts helps the devs for a fast proper patch.
This should now be solved in the latest pre-release (v1.1.39). Thanks @Tripete for the suggested fix.
Want to wait to close the issue however until I've gotten confirmation of the fix in case there's anything else
Unfortunately, I installed extension version v1.1.40, and cannot open the correct path YAML file
Step 1 > new rule yaml path
.continue\rules\new-rule.yaml
Step 2 > Click Edit, then open the original config.yaml
I use a windows machine to remote into the linux server.
I installed the latest version 1.1.42,, but still have same problem.
All configuration files under ".continue/rules" cannot be loaded, and new rules cannot be created.
Hope someone can help me take a look.
This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue.
This issue was closed because it wasn't updated for 10 days after being marked stale. If it's still important, please reopen + comment and we'll gladly take another look!