vscode icon indicating copy to clipboard operation
vscode copied to clipboard

MONGOSH execute all error: extensionPath is undefined

Open kenlfg opened this issue 3 years ago • 1 comments

Bug Report

Current Behavior

  1. Installed the extension in VS Code.
  2. Installed mongosh locally
  3. Installed mongodb community to have a local DB to test against
  4. Connected to the local instance
  5. Wrote a basic playground script
  6. Clicked Play in the upper right corner of the UI
  7. 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.).
  8. 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

kenlfg avatar Jul 08 '22 20:07 kenlfg

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

brammitch avatar Sep 23 '22 16:09 brammitch

Hey @kenlfg, are you running a normal VS Code installation or some remote version of it?

alenakhineika avatar Feb 06 '23 16:02 alenakhineika

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

kenlfg avatar Feb 06 '23 21:02 kenlfg

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...

kenlfg avatar Feb 06 '23 21:02 kenlfg

Would be great if you could try it again with the latest version of the extension! Currently, it is v0.10.0.

alenakhineika avatar Feb 07 '23 13:02 alenakhineika

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!

kenlfg avatar Feb 10 '23 08:02 kenlfg