Skip to content

[BUG]: Better multi-root workspace support in VS Code #250

@kunlinglio

Description

@kunlinglio

Issue Description

When opening a multi-root workspace in VS Code, for example a .code-workspace file, the extension crashed.

Operating System

macOS

Editor

VSCode

Codebook Version

v0.3.38

Configuration

Steps to Reproduce

  1. Install latest version of codebook VS Code extension (0.0.1 for now).
  2. Get a multi-root workspace. For example, use my path-server repo:
    git clone https://github.com/kunlinglio/path-server.git
    cd path-server
    code .vscode/path-server.code-workspace
  3. Then, you will see the error message from codebook.

Expected Behavior

Initialize codebook successfully.

Actual Behavior

The extension crashed and showed several error messages:

  • Codebook client: couldn't create connection to server.
  • Server initialization failed.

Code Sample


Log Output

Using cached codebook binary version v0.3.38
Starting Codebook (--root=/Users/lkl/Code/tmp/path-server serve) for Path Server
[Info  - 3:25:14 PM] [codebook_lsp] INFO: Starting Codebook Language Server v0.3.38-release...
Starting Codebook (--root=/Users/lkl/Code/tmp/path-server/extensions/vscode serve) for VS Code Extension
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Client options: ClientInitializationOptions { log_level: Info, global_config_path: None, check_while_typing: true, diagnostic_severity: Information }
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: LSP logger attached to client with log level: INFO
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Server ready!
[Info  - 3:25:14 PM] [codebook_config] INFO: No global config found, using default
[Info  - 3:25:14 PM] [codebook_config] INFO: No project config found, using default
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Project config: /Users/lkl/Code/tmp/path-server/codebook.toml
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Global config: /Users/lkl/.config/codebook/codebook.toml
[Info  - 3:25:14 PM] [codebook_lsp] INFO: Starting Codebook Language Server v0.3.38-release...
[Error - 3:25:14 PM] Server initialization failed.
Error: command 'codebook.addWord' already exists
	at Eg.registerCommand (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:47251)
	at Object.registerCommand (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:639:135009)
	at Zf.register (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:37:72694)
	at Zf.initialize (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:37:72277)
	at ap.initializeFeatures (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:42:6095)
	at ap.doInitialize (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:39:7423)
	at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
	at async ap.start (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:39:4452)
	at async pR (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:59889)
	at async dk (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:59220)
	at async ku (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:58989)
	at async lk (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:58932)
	at async Mb._activate (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:15965)
	at async Mb._waitForDepsThenActivate (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:15907)
	at async Mb._initialize (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:15274)
[Error - 3:25:14 PM] Codebook client: couldn't create connection to server.
Error: command 'codebook.addWord' already exists
	at Eg.registerCommand (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:47251)
	at Object.registerCommand (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:639:135009)
	at Zf.register (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:37:72694)
	at Zf.initialize (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:37:72277)
	at ap.initializeFeatures (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:42:6095)
	at ap.doInitialize (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:39:7423)
	at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
	at async ap.start (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:39:4452)
	at async pR (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:59889)
	at async dk (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:59220)
	at async ku (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:58989)
	at async lk (/Users/lkl/.vscode/extensions/blopker.codebook-vscode-0.0.1/dist/extension.js:44:58932)
	at async Mb._activate (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:15965)
	at async Mb._waitForDepsThenActivate (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:15907)
	at async Mb._initialize (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:501:15274)
Error: command 'codebook.addWord' already exists
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Client options: ClientInitializationOptions { log_level: Info, global_config_path: None, check_while_typing: true, diagnostic_severity: Information }
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: LSP logger attached to client with log level: INFO
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Server ready!
[Info  - 3:25:14 PM] [codebook_config] INFO: No global config found, using default
[Info  - 3:25:14 PM] [codebook_config] INFO: No project config found, using default
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Project config: /Users/lkl/Code/tmp/path-server/extensions/vscode/codebook.toml
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Global config: /Users/lkl/.config/codebook/codebook.toml
[Info  - 3:25:14 PM] [codebook_lsp::lsp] INFO: Server shutting down
[Error - 3:25:14 PM] Server process exited with code 0.

Additional Context

Actually, handling multi-root workspaces in VS Code can be quite difficult. If needed, I'm willing to investigate this further and can open a PR for it if I have time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions