vscode-circuitpython
vscode-circuitpython copied to clipboard
[BUG] Errors when CIRCUITPY folder is not added to VScode workspace
Describe the bug The extension was not loading properly and no commands would work. In the Output log for extension host, I was seeing the following error:
[2022-01-02 13:41:50.350] [exthost] [error] Activating extension joedevivo.vscode-circuitpython failed due to an error:
[2022-01-02 13:41:50.350] [exthost] [error] TypeError: Cannot read property 'forEach' of undefined
at LibraryManager.getProjectRoot (c:\Users\username\.vscode\extensions\joedevivo.vscode-circuitpython-0.1.15\out\librarymanager\libraryManager.js:191:43)
at LibraryManager.getProjectLibDir (c:\Users\username\.vscode\extensions\joedevivo.vscode-circuitpython-0.1.15\out\librarymanager\libraryManager.js:234:37)
at LibraryManager.<anonymous> (c:\Users\username\.vscode\extensions\joedevivo.vscode-circuitpython-0.1.15\out\librarymanager\libraryManager.js:114:39)
at Generator.next (<anonymous>)
at fulfilled (c:\Users\username\.vscode\extensions\joedevivo.vscode-circuitpython-0.1.15\out\librarymanager\libraryManager.js:5:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I was able to fix the issue in VScode by going to File > Add Folder to Workspace > CIRCUITPY (D:) root folder and accepting the popup dialog.
When you are doing a CP Project flip this approach around, Instead of adding the CIRCUITPY folder to an existing workspace, instead don't create the workspace.json file yet. Instead, plug the Microcontroller in and make sure the CIRCUITPY is mounted and ready, then in VSC do a "open a folder" and then pick that folder. Then when it's done creating the .vscode folder you then go to the menu in VSC do a "save workspace as...", put it in the CIRCUITPY directory. Now after that, if you want to do a project then connect the device, mount CIRCUITPY and go to that folder and open the workspace.json using the option "Open workspace from the file" then you will have no errors. Also once the workplace file is created then pick your board, bottom right in VSC and workplace.json will be updated with the correct stuff.