-
Notifications
You must be signed in to change notification settings - Fork 665
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
Error creating file in .dev version: No file system handle registered #1404
Comments
Which browser are you using? And could you see if vscode.dev works? |
Chrome. And yes, vscode.dev works otherwise, including other extensions. I have used vscode.dev for a long time. It does not work either in Safari, where I get this error message: Command 'Foam: Create New Note' resulted in an error |
Tested at work on a Windows 11 machine, same result: Command 'Foam: Create New Note' resulted in an error Full URL: https://vscode.dev/github/markschaver/Notes. Same at https://github.dev/markschaver/Notes/. Command 'Foam: Create New Note' resulted in an error |
During my development work on this I only tested this on local folders. Doing some research it seems we need to add some capabilities to support remote repositories. See: https://code.visualstudio.com/blogs/2021/06/10/remote-repositories#_ensuring-your-extension-works-in-a-virtual-workspace I will have a look at this in the upcoming weeks. |
I've made some progress in this area. Will document my findings here. (@riccardoferretti FYI). Ultimately, a re mote repository works as a virtual file system. This differs to the normal behaviour of Foam which in some areas looks at absolute paths or simply core functions that work differently. This requires us to handle some paths differently. For example, the behaviour of const uris = await workspace.findFiles(
folder.uri.scheme === 'vscode-vfs'
? '**/*'
: new RelativePattern(folder.uri.path, '**/*'),
new RelativePattern(
folder.uri.path,
`{${excludePatterns.get(folder.name).join(',')}}`
)
); Note: Here I detect that the workspace folder is of the scheme With this little change, Foam can load the graph and get most things working. However, Foam can't create files right now. I need to look into that behaviour, but will do with a fresh mind. So, making some steps. However, I need some time to check some things before fully publishing a solution. |
Mmmm... I am not sure, the |
I am thinking RelativePattern causes the issue, but need to verify that. |
So, did some digging into the way we use Locally: the Remote Repository: the That is odd. So I've done some research and found out that const uris = await workspace.findFiles(
new RelativePattern(folder, '**/*'),
new RelativePattern(
folder,
`{${excludePatterns.get(folder.name).join(',')}}`
)
); Resulting into the following |
I've done some research on writing files, for example the daily note. The main issue here is that So, I need some reflection on how to solve this. Especially as the only way to know if you are active on a virtual workspace is determined via the |
Thanks for the research @pderaaij - I will do a deep dive this weekend, I feel there are a few things I don't understand enough to give informed support. I am keen to keep to a bare minimum the difference between the code for the native and the web extension, and am willing to make some tweaks to the assumptions in Foam to make that happen (e.g. remove any support we might have for files that live outside the workspace). Let me have a think, and let me know if you have any update on your side as well, thanks! |
The RelativePattern one is a safe one and won't impact that much. The NoteFactory change will be more impactful, but not sure if this is the proper way to go. Regarding research. The most important thing is the structure of |
@riccardoferretti Would be great if you can have a look at it this weekend. Currently, I feel the best approach is to add an optional /**
*
* @param value Creates an URI pointing to the given path of the file.
*
* @param inContext Can be used to point to the path in a given context. For example,
* to be used for schemes other then 'file' e.g. 'vscode-vfs'
* @returns URI object with path pointing to the given value.
*/
static file(value: string, inContext: URI = undefined): URI {
const [path, authority] = pathUtils.fromFsPath(value);
if (inContext !== undefined) {
return new URI({ ...inContext, path: path });
}
return new URI({ scheme: 'file', authority, path });
} Note: need to think about authority here. Requires some additional research. We can then use it at the appropriate place. For example in let newFilePath = template.metadata.has('filepath')
? URI.file(
template.metadata.get('filepath'),
URI.parse(workspace.workspaceFolders[0].uri.toString())
)
: filepathFallbackURI; That ensures we give the vscode context to Please let me know what you think. I haven't put this into code for now. Just some prototyping. |
Thanks for the write up @pderaaij - I have gone through your comments and the code, I think I roughly understand the problem. Before digging too deeply I wanted to reproduce the issue, and although I can see the problem in github.dev, I have been unable to reproduce the issue in other environments. |
You need the So. I install this extension and then open a GitHub repo that I used for Foam. |
@pderaaij I have looked a bit more at the issue. |
Yeah good point, there are a couple of things in the command itself that need to be addressed as well |
@markschaver do you have any specific settings for your daily journal? For example, the location? With the defaults it works in my situation. Would like to verify my hypothesis. |
No. My first thought was that I needed to set a directory for the daily note, but that didn't work either. |
@pderaaij if I understand where you are going, I agree we will have an issue because currently we support templates outside of the workspace, and we will need to remove such functionality (unfortunate, but I feel there are workarounds, and having everything self-contained in the workspace is a stronger foundation). |
@riccardoferretti Not too concerned about templates outside the workspace, to be honest. The virtual file system is built around the root folder, and outside that root, it simply isn't part of the virtual file system. I need to research a bit more, but a problem could be in the use of
as used in |
@markschaver I am having some trouble replicating the issue. This is what I do. I go to my personal repository on GitHub. I press What was necessary for me was to restart the extensions to make sure I had the latest. Would you mind confirming if you have the latest version in your online environment? Furthermore, curious which browser you are using. |
So, same result for me on Safari and Chrome on MacOS 15.1.1 and with Chrome on Windows 11. |
Describe the bug
On a Mac, when I attempt to create a new file or open a daily note in the .dev version of Foam, I get an error message: No file system handle registered. I am using v0.26.1 of the extension.
Errors:
Command 'Foam: Create New Note' resulted in an error
Unable to write file '/markschaver/foamtest/Test.md' (Unavailable (FileSystemError): Error: No file system handle registered (/markschaver))
Command 'Foam: Open Daily Note' resulted in an error
Unable to write file '/markschaver/foamtest/2024-10-09.md' (Unavailable (FileSystemError): Error: No file system handle registered (/markschaver))
Small Reproducible Example
https://github.dev/markschaver/foamtest/blob/master/readme.md
Steps to Reproduce the Bug or Issue
Expected behavior
I expect the files to be created. They are not. I am also unable to create new files by clicking on a wiki link.
Screenshots or Videos
No response
Operating System Version
macOS (though experienced same problem on Windows 11 with v26.)
Visual Studio Code Version
Latest .dev version.
Additional context
No response
The text was updated successfully, but these errors were encountered: