vscode
vscode copied to clipboard
MONGOSH execute all error: extensionPath is undefined
Bug Report
Current Behavior
- Installed the extension in VS Code.
- Installed mongosh locally
- Installed mongodb community to have a local DB to test against
- Connected to the local instance
- Wrote a basic playground script
- Clicked Play in the upper right corner of the UI
- The toast indicating something's happening (too fast to read) shows and goes away. No obvious results seen (no separate tab, nothing showing in the "Playground output" output pane, etc.).
- MongoDB Language Server output shows: "MONGOSH execute all error: extensionPath is undefined"
Prior to the error, I see this:
EXPORT TO LANGUAGE state: { databaseName: 'local', collectionName: 'startup_log', isObject: false, isArray: false, isObjectKey: false, isShellMethod: false, isUseCallExpression: false, isDbCallExpression: false, isCollectionName: false, isAggregationCursor: false, isFindCursor: false }
Note that using mongosh directly to run the same script via command line in the VS Code terminal window results in the expected outcome.
Code/Gist
Code used:
`use('local');
db.startup_log.find();`
Outcome is the same whether I select and use the Run Selected command or just click the Play button.
Expected Behavior/Code
I expect to get results (that local log table has 1 document per MongoDB Compass).
Environment
- node.js / npm versions: v16.15.1 / 8.0.0
- OS: Windows 11
Possible Solution
Additional Context/Screenshots
I was running into this exact same error. What fixed the issue for me was making sure that the MongoDB for VS Code extension was installed both locally and on the remote.
When I initially installed the extension, I was already connected to my remote, and the extension installed in the remote only. To test this, I closed the remote, installed the extension locally, then reconnected to my remote. Now that the extension was installed both locally and remote, the Playground works as expected.
Environment:
- VSCode: 1.67.1
- MongoDB for VS Code: 0.9.3
- Local:
- node.js / npm versions: 16.14.0 / 8.3.1
- OS: Windows 10.0.19043
- Remote:
- node.js / npm versions: 16.15.1 / 8.11.0
- OS: Red Hat Enterprise Linux Server 7.9
- mongosh: 1.0.5
Hey @kenlfg, are you running a normal VS Code installation or some remote version of it?
Normal installation:
Version: 1.75.0 (system setup) Commit: e2816fe719a4026ffa1ee0189dc89bdfdbafb164 Date: 2023-02-01T15:23:45.584Z Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Windows_NT x64 10.0.22621 Sandboxed: No
It's been a while since I tried this so I can see if I can still reproduce it as there have been a few VS Code updates since...
Would be great if you could try it again with the latest version of the extension! Currently, it is v0.10.0.
Sorry for the delay in responding. It looks like the issue was resolved! With v0.10.0, going through the steps to reproduce produces the expected result now instead of the error.
It >has< been a while so it's possible someone managed to fix the issue since I posted this.
Thanks!