vscode-spellright icon indicating copy to clipboard operation
vscode-spellright copied to clipboard

Cannot add word to a workspace dictionary

Open Serhioromano opened this issue 2 years ago • 9 comments

When I try to add word to workspace dictionary it says

A system error occurred (ENOENT: no such file or directory, open)

Serhioromano avatar Oct 20 '22 07:10 Serhioromano

Could you give some more information e.g. a hint about what OS are we talking about? Do you have a write/execute rights to the directory?

bartosz-antosik avatar Oct 20 '22 08:10 bartosz-antosik

To what directory? I have windows. Directory is trusted. Other files like settings.json are created normally with VS Code. Tell me what file and where should be created I'll try to create manually.

Serhioromano avatar Oct 20 '22 12:10 Serhioromano

Also having this issue on macOS; tried manually creating .vscode/spellright.dict but no joy. Adding a word to the user dictionary works fine. Spell Right v3.0.90/VSCode 1.73.0

drejom avatar Nov 08 '22 13:11 drejom

@bartosz-antosik I ran a few tests. When I reopen folder in Windows and Add to workspace dictionary works and it adds file to .vscode/spellright.dict. In WSL Remote there is an error. It it obviously a problem with path somewhere because in WSL I have change mode to 777 for that file. It should be writable. Also, if I add words to dictionary it does not apply. It means that the path is different for WSL and it looks for different directory.

Serhioromano avatar Nov 30 '22 05:11 Serhioromano

@bartosz-antosik I was try to debug your extension but there are some tech that I cannot launch, I would place console.log(this.getWorkspaceDictionaryPath()) on Windows WSL Ubuntu Remote and see what it say here https://github.com/bartosz-antosik/vscode-spellright/blob/a25eb66dd817abb778f8731948b30f791269641c/src/spellright.js#L1994

You have very strange code there

vscode.workspace.getWorkspaceFolder(editor.document.uri).uri.fsPath

Why? Here is what I use in my extension

let rootPath: string =
        vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0
            ? vscode.workspace.workspaceFolders[0].uri.fsPath
            : "";

Works in multi workspace projects.

Serhioromano avatar Nov 30 '22 06:11 Serhioromano

I'm having the same issue. I've tried deleting the spellright.dict file, and the whole .vscode folder, and then trying to make the extension generate a new one, but it continues to throw the same error.

It seems to happen for every folder I have in WSL, but, critically, once it's thrown the error one time, it's cursed the directory forever. Including if I open it as non-WSL later.

tjwieg avatar Mar 02 '23 17:03 tjwieg

same error for me here with wsl, user dict works fine, thought i don't know where this file is. Tried even to create the spellright.dict file inside of .vscode folder but the error message remains the same:

image

piradata avatar Mar 31 '23 06:03 piradata

I have the same error here with a VSCode running on windows 10 and connected to a remote Linux host (ubuntu 20.04). Note that even if the extension is installed both on the local host (the windows laptop) and the remote host (linux), the extension tab in vscode says when hovering on the remote spellright extension: "This extension is enabled in the local extension host because it prefers to run there". That may be the culprit as the code I am working on does not exist on the local host.

Spellright version: v.3.0.118 VSCode version: 1.85.1 (2023-12-13)

Here is the content of some log (Output/Extension host):

2024-01-03 14:12:26.827 [error] Error: ENOENT: no such file or directory, open
	at Object.openSync (node:fs:603:3)
	at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1869)
	at SpellRight.addWordToDictionary (c:\Users\redacted\.vscode\extensions\ban.spellright-3.0.118\src\spellright.js:1832:29)
	at SpellRight.addWordToWorkspaceDictionary (c:\Users\redacted\.vscode\extensions\ban.spellright-3.0.118\src\spellright.js:1843:22)
	at SpellRight.addFromSelectionToWorkspaceDictionary (c:\Users\redacted\.vscode\extensions\ban.spellright-3.0.118\src\spellright.js:1757:26)
	at d.h (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:141:140094)
	at d.$executeContributedCommand (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:141:140954)
	at l.S (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:10829)
	at l.Q (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:10595)
	at l.M (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:9685)
	at l.L (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:8764)
	at f.value (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:7567)
	at n.y (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
	at n.fire (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
	at o.fire (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:103:14039)
	at f.value (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:7903)
	at n.y (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902)
	at n.fire (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119)
	at o.fire (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:103:14039)
	at MessagePortMain.<anonymous> (c:\Users\redacted\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:6183)
	at MessagePortMain.emit (node:events:513:28)
	at MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367) spellright.addFromSelectionToWorkspaceDictionary {"value":"ban.spellright","_lower":"ban.spellright"}

#566 seems related...

mm-andritz avatar Jan 03 '24 19:01 mm-andritz

Maybe relevant: I get the same error, and I use VSCode Insiders to edit a project via Remote-SSH to a brand-new VM with an Ubuntu installation.

When I edit the same project but in a local directory, adding words to the workspace dictionary works as expected.

VSCode Insider runs on Windows 10, but the ExtensionHost runs on Ubuntu 22. The URI to the settings file can not be opened using the "path" attribute because it looks like "remote-ssh://..../path.../settings.json"

I think https://github.com/bartosz-antosik/vscode-spellright/issues/532#issuecomment-1331713741 is on to something regarding the workspace folder URIs, although the example code he gives is wrong because it hardcodes vscode.workspace.workspaceFolders[0] - in a workspace with more than one folder, this would only work for files that happen to be in the first folder of the workspace; ie, it is broken for multi-folder workspaces.

I suggest an easy way to reproduce is to edit a document on a remote server via Remote-SSH. Examples above also refer to WSL, which is another remoting tech (supposed the URI's for files accessed though WSL are "remote-wsl://.../..." or some such). Remote files must be accessed via the the URI, not as regular local files, because only the extension that manages the particular scheme (remote-ssh:, remote-wsl:, blah-blah:, etc) can interpret the path and be able to resolve the URI to some content.

The scheme in file URI's is arbitrary and up to some other extension to choose and interpret, your code cannot infer anything from the parts of the URI.

drok avatar Apr 11 '24 19:04 drok